providers/oauth2: bug fixes from conformance testing (#15056)
* check authorize request param earlier Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix basic suite? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * another actual fix; don't return access_token when using response_type id_token Signed-off-by: Jens Langhammer <jens@goauthentik.io> * only run basic+implicit for now, fix other tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> # Conflicts: # tests/openid_conformance/test_conformance.py --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		@ -387,8 +387,7 @@ class TestAuthorize(OAuthTestCase):
 | 
				
			|||||||
            self.assertEqual(
 | 
					            self.assertEqual(
 | 
				
			||||||
                response.url,
 | 
					                response.url,
 | 
				
			||||||
                (
 | 
					                (
 | 
				
			||||||
                    f"http://localhost#access_token={token.token}"
 | 
					                    f"http://localhost#id_token={provider.encode(token.id_token.to_dict())}"
 | 
				
			||||||
                    f"&id_token={provider.encode(token.id_token.to_dict())}"
 | 
					 | 
				
			||||||
                    f"&token_type={TOKEN_TYPE}"
 | 
					                    f"&token_type={TOKEN_TYPE}"
 | 
				
			||||||
                    f"&expires_in={int(expires)}&state={state}"
 | 
					                    f"&expires_in={int(expires)}&state={state}"
 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
@ -563,7 +562,6 @@ class TestAuthorize(OAuthTestCase):
 | 
				
			|||||||
                "url": "http://localhost",
 | 
					                "url": "http://localhost",
 | 
				
			||||||
                "title": f"Redirecting to {app.name}...",
 | 
					                "title": f"Redirecting to {app.name}...",
 | 
				
			||||||
                "attrs": {
 | 
					                "attrs": {
 | 
				
			||||||
                    "access_token": token.token,
 | 
					 | 
				
			||||||
                    "id_token": provider.encode(token.id_token.to_dict()),
 | 
					                    "id_token": provider.encode(token.id_token.to_dict()),
 | 
				
			||||||
                    "token_type": TOKEN_TYPE,
 | 
					                    "token_type": TOKEN_TYPE,
 | 
				
			||||||
                    "expires_in": "3600",
 | 
					                    "expires_in": "3600",
 | 
				
			||||||
 | 
				
			|||||||
@ -150,12 +150,12 @@ class OAuthAuthorizationParams:
 | 
				
			|||||||
        self.check_redirect_uri()
 | 
					        self.check_redirect_uri()
 | 
				
			||||||
        self.check_grant()
 | 
					        self.check_grant()
 | 
				
			||||||
        self.check_scope(github_compat)
 | 
					        self.check_scope(github_compat)
 | 
				
			||||||
        self.check_nonce()
 | 
					 | 
				
			||||||
        self.check_code_challenge()
 | 
					 | 
				
			||||||
        if self.request:
 | 
					        if self.request:
 | 
				
			||||||
            raise AuthorizeError(
 | 
					            raise AuthorizeError(
 | 
				
			||||||
                self.redirect_uri, "request_not_supported", self.grant_type, self.state
 | 
					                self.redirect_uri, "request_not_supported", self.grant_type, self.state
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
 | 
					        self.check_nonce()
 | 
				
			||||||
 | 
					        self.check_code_challenge()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def check_grant(self):
 | 
					    def check_grant(self):
 | 
				
			||||||
        """Check grant"""
 | 
					        """Check grant"""
 | 
				
			||||||
@ -630,7 +630,6 @@ class OAuthFulfillmentStage(StageView):
 | 
				
			|||||||
        if self.params.response_type in [
 | 
					        if self.params.response_type in [
 | 
				
			||||||
            ResponseTypes.ID_TOKEN_TOKEN,
 | 
					            ResponseTypes.ID_TOKEN_TOKEN,
 | 
				
			||||||
            ResponseTypes.CODE_ID_TOKEN_TOKEN,
 | 
					            ResponseTypes.CODE_ID_TOKEN_TOKEN,
 | 
				
			||||||
            ResponseTypes.ID_TOKEN,
 | 
					 | 
				
			||||||
            ResponseTypes.CODE_TOKEN,
 | 
					            ResponseTypes.CODE_TOKEN,
 | 
				
			||||||
        ]:
 | 
					        ]:
 | 
				
			||||||
            query_fragment["access_token"] = token.token
 | 
					            query_fragment["access_token"] = token.token
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user