@@ -783,3 +783,96 @@ def test_custom_token_verifier_with_audience_allowed(
783783 validate_proxy (mock_get , proxy , oidc_config )
784784 assert proxy ._extra_authorize_params == {"audience" : "test-audience" }
785785 assert proxy ._extra_token_params == {"audience" : "test-audience" }
786+
787+ def test_extra_authorize_params_initialization (self , valid_oidc_configuration_dict ):
788+ """Test extra authorize params initialization."""
789+ with patch (
790+ "fastmcp.server.auth.oidc_proxy.OIDCConfiguration.get_oidc_configuration"
791+ ) as mock_get :
792+ oidc_config = OIDCConfiguration .model_validate (
793+ valid_oidc_configuration_dict
794+ )
795+ mock_get .return_value = oidc_config
796+
797+ proxy = OIDCProxy (
798+ config_url = TEST_CONFIG_URL ,
799+ client_id = TEST_CLIENT_ID ,
800+ client_secret = TEST_CLIENT_SECRET ,
801+ base_url = TEST_BASE_URL ,
802+ jwt_signing_key = "test-secret" ,
803+ extra_authorize_params = {
804+ "prompt" : "consent" ,
805+ "access_type" : "offline" ,
806+ },
807+ )
808+
809+ validate_proxy (mock_get , proxy , oidc_config )
810+
811+ assert proxy ._extra_authorize_params == {
812+ "prompt" : "consent" ,
813+ "access_type" : "offline" ,
814+ }
815+ # Token params should be empty since we didn't set them
816+ assert proxy ._extra_token_params == {}
817+
818+ def test_extra_token_params_initialization (self , valid_oidc_configuration_dict ):
819+ """Test extra token params initialization."""
820+ with patch (
821+ "fastmcp.server.auth.oidc_proxy.OIDCConfiguration.get_oidc_configuration"
822+ ) as mock_get :
823+ oidc_config = OIDCConfiguration .model_validate (
824+ valid_oidc_configuration_dict
825+ )
826+ mock_get .return_value = oidc_config
827+
828+ proxy = OIDCProxy (
829+ config_url = TEST_CONFIG_URL ,
830+ client_id = TEST_CLIENT_ID ,
831+ client_secret = TEST_CLIENT_SECRET ,
832+ base_url = TEST_BASE_URL ,
833+ jwt_signing_key = "test-secret" ,
834+ extra_token_params = {"custom_param" : "custom_value" },
835+ )
836+
837+ validate_proxy (mock_get , proxy , oidc_config )
838+
839+ # Authorize params should be empty since we didn't set them
840+ assert proxy ._extra_authorize_params == {}
841+ assert proxy ._extra_token_params == {"custom_param" : "custom_value" }
842+
843+ def test_extra_params_merge_with_audience (self , valid_oidc_configuration_dict ):
844+ """Test that extra params merge with audience, with user params taking precedence."""
845+ with patch (
846+ "fastmcp.server.auth.oidc_proxy.OIDCConfiguration.get_oidc_configuration"
847+ ) as mock_get :
848+ oidc_config = OIDCConfiguration .model_validate (
849+ valid_oidc_configuration_dict
850+ )
851+ mock_get .return_value = oidc_config
852+
853+ proxy = OIDCProxy (
854+ config_url = TEST_CONFIG_URL ,
855+ client_id = TEST_CLIENT_ID ,
856+ client_secret = TEST_CLIENT_SECRET ,
857+ base_url = TEST_BASE_URL ,
858+ audience = "original-audience" ,
859+ jwt_signing_key = "test-secret" ,
860+ extra_authorize_params = {
861+ "prompt" : "consent" ,
862+ "audience" : "overridden-audience" , # Should override the audience param
863+ },
864+ extra_token_params = {"custom" : "value" },
865+ )
866+
867+ validate_proxy (mock_get , proxy , oidc_config )
868+
869+ # User's extra_authorize_params should override audience
870+ assert proxy ._extra_authorize_params == {
871+ "audience" : "overridden-audience" ,
872+ "prompt" : "consent" ,
873+ }
874+ # Token params should have both audience (from audience param) and custom
875+ assert proxy ._extra_token_params == {
876+ "audience" : "original-audience" ,
877+ "custom" : "value" ,
878+ }
0 commit comments