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

Add state parameter to the authorization code request #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion keystoneauth_oidc/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pkce
import socket
import webbrowser
import uuid

from keystoneauth1 import _utils as utils
from keystoneauth1 import access
Expand Down Expand Up @@ -164,6 +165,7 @@ def __init__(self, auth_url, identity_provider, protocol, client_id,
self.redirect_uri = "http://%s:%s" % (self.redirect_host, self.redirect_port)
self.code_verifier = None
self.code_challenge = None
self.state = uuid.uuid4().hex
if client_secret in ['', None]:
self.code_verifier, self.code_challenge = pkce.generate_pkce_pair()

Expand Down Expand Up @@ -201,7 +203,8 @@ def _get_authorization_code(self, session):
payload = {"client_id": self.client_id,
"response_type": "code",
"scope": self.scope,
"redirect_uri": self.redirect_uri}
"redirect_uri": self.redirect_uri,
"state": self.state}

if self.code_challenge is not None:
payload.update({
Expand Down
3 changes: 2 additions & 1 deletion keystoneauth_oidc/tests/unit/test_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def test__get_authorization_code(self,
payload = {"client_id": self.CLIENT_ID,
"response_type": "code",
"scope": self.plugin.scope,
"redirect_uri": self.plugin.redirect_uri}
"redirect_uri": self.plugin.redirect_uri,
"state": self.plugin.state}

url = "%s?%s" % (self.AUTHORIZATION_ENDPOINT,
urllib.parse.urlencode(payload))
Expand Down