Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The nonce is not included in the authorization url if "openid" is not the first scope #449

Closed
KrYpTeD974 opened this issue Apr 6, 2022 · 0 comments
Assignees
Labels

Comments

@KrYpTeD974
Copy link

Describe the bug

The nonce is not included in the authorization url if "openid" is not the first scope because it only checks if the scope startswith openid

To Reproduce

A minimal example to reproduce the behavior:

Expected behavior

The nonce should be included in the authorization url even if it is not the first scope.

Environment:

  • OS: Windows 10
  • Python Version: 3.9
  • Authlib Version: 1.0.0

Additional context

Add any other context about the problem here.

The problem seems to be in the _create_oauth2_authorization_url method of the integrations/base_client/sync_app.py file.

        scope = kwargs.get('scope', client.scope)
        if scope and scope.startswith('openid'):
            # this is an OpenID Connect service
            nonce = kwargs.get('nonce')
            if not nonce:
                nonce = generate_token(20)
                kwargs['nonce'] = nonce
            rv['nonce'] = nonce

Checking only if the scope starts with openid could lead to errors difficult to debug.
Maybe it could be replaced by : 'openid' in scope.split(" ").

Is this intended?

@KrYpTeD974 KrYpTeD974 added the bug label Apr 6, 2022
@lepture lepture closed this as completed in 1c7a2c4 Apr 6, 2022
coopfeathy added a commit to coopfeathy/authlib-django that referenced this issue Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants