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

feat: Authorization Code Flow with PKCE #92

Merged
merged 8 commits into from
Jan 3, 2024
Merged

feat: Authorization Code Flow with PKCE #92

merged 8 commits into from
Jan 3, 2024

Conversation

maeb
Copy link
Member

@maeb maeb commented Dec 20, 2023

This PR implements Authorization Code Flow with Proof Key for Code Exchange (PKCE).

PKCE was originally designed to protect the authorization code flow in mobile apps, but its ability to prevent authorization code injection makes it useful for every type of OAuth client, even web apps that use client authentication.

https://oauth.net/2/pkce/

This PR also seeks to standardise the OIDC login flow such that specifics about a particular authorization server implementation is removed.

Copy link
Contributor

@trym-b trym-b left a comment

Choose a reason for hiding this comment

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

Nicely logically divded commits

config/config.go Show resolved Hide resolved
connection/auth.go Show resolved Hide resolved
connection/auth.go Show resolved Hide resolved
connection/auth.go Outdated Show resolved Hide resolved
connection/auth.go Show resolved Hide resolved
connection/auth.go Show resolved Hide resolved
@maeb maeb force-pushed the feat/pkce branch 2 times, most recently from df75d0b to b256e5a Compare January 3, 2024 12:43
@maeb
Copy link
Member Author

maeb commented Jan 3, 2024

@trym-b ready for next round.

maeb added 5 commits January 3, 2024 14:15
This commit removes a scope that is not defined by the OpenID Connect
specification and DOES NOT WORK with the Keycloak authorization server.

The specification states that scope values used that are not
understood by an application should be IGNORED, but apparently not all
authorization servers adheres to the spec.

Ref: https://openid.net/specs/openid-connect-basic-1_0.html#Scopes
This commit is motivated by code readability.
maeb added 3 commits January 3, 2024 14:25
This commit implements Proof Key for Code Exchange (PKCE) for the
Authorization Code Flow.

See https://oauth.net/2/pkce/ and https://tools.ietf.org/html/rfc7636.

PKCE ensures that the client application exchanging the authorization
code is the same client application that requested it and that the
authorization code was not stolen and injected in a different session.
A client secret allows the authorization server to determine the
identity of the client.

This is recommended for confidential clients and PKCE is an
additional layer of security.

Since this application is considered a public client it does not
make sense to use a default client secret that is hardcoded in the
application.

The reason it was there in the first place was lack of knowledge.
This commit does not store the client secret in the configuration
file if it is empty when logging in. This is the case in a normal
login scenario when using the OpenID Connect Authorization Code
Flow with PKCE.

As stated in the previous commit this application is considered a
public client and does not require the user to keep the client
secret confidential. It is still possible to manually set the
client secret field in the configuration file, but it will be
removed when logging out.
@maeb maeb merged commit b1b1fb7 into main Jan 3, 2024
2 checks passed
@maeb maeb deleted the feat/pkce branch January 3, 2024 13:27
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.

2 participants