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 support for authorization code grant with PKCE for distributed apps #1067

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ls-sean-fraser
Copy link

@ls-sean-fraser ls-sean-fraser commented Jun 7, 2024

Add support for "Authorization Code Grant with PKCE" flow to allow distributed apps to securely authenticate with an OAuth server without needing to embed secrets within the distributed application, as these can be easily exposed by decompiling the application binaries.

  • Move handlers for code challenge from OIDC AuthorizeController to the base AuthorizeController, so that non-OIDC flows can leverage it as well
  • Add mechanism to enforce PKCE code challenges for public clients
  • Add mechanism to configure supported code challenge methods
  • Change code_verifier comparison to use hash_equals() to avoid timing attacks
  • Added tests for all PKCE code challenge flows

Reference:

move handlers for code challenge from OIDC Authorization Controller to the base authorization controller, so that non-OIDC flows can leverage it as well

Add mechanism to enforce PKCE code challenges for public clients

Add mechanism to configure supported code challenge methods

change code_verifier comparison to use hash_equals() to avoid timing attacks

added tests for all PKCE code challenge flows
@@ -88,6 +99,8 @@ public function __construct(ClientInterface $clientStorage, array $responseTypes
'require_exact_redirect_uri' => true,
'redirect_status_code' => 302,
'enforce_pkce' => false,
'enforce_pkce_for_public_clients' => false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ this should probably default to true for new installs, but that could be a breaking change for existing installs. Leaving this at false allows for releasing as a minor version. Would recommend defaulting to true for the next major version.

Comment on lines +376 to +377
if ($this->clientStorage instanceof ClientCredentialsInterface) {
$isPublic = $this->clientStorage->isPublicClient($client_id);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ not sure why there are two interfaces, but the property is only typed to the higher level one which doesn't have the method we need.

/**
* @var mixed
*/
protected $code_challenge;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ these properties and their behavior moved to the parent class

@@ -173,6 +173,8 @@ public function __construct($storage = array(), array $config = array(), array $
'require_exact_redirect_uri' => true,
'allow_implicit' => false,
'enforce_pkce' => false,
'enforce_pkce_for_public_clients' => false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ same comment about default value

@ls-sean-fraser
Copy link
Author

@bshaffer any chance you could give this PR a glance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant