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 PKCE config parameter #486

Merged
merged 2 commits into from
Aug 5, 2022

Conversation

DriverCat
Copy link
Contributor

@DriverCat DriverCat commented Aug 3, 2022

This PR adds new config option use_pkce_with_authorization_code_grant with default value set to false.
This new parameter allows to authorize through Authorization Code Grant with PKCE, because if set to true, it enables swagger-ui option usePkceWithAuthorizationCodeGrant. #485

Comment on lines 70 to 72
ui.initOAuth({
usePkceWithAuthorizationCodeGrant: "{!! (bool)config('l5-swagger.defaults.ui.authorization.use_pkce_with_authorization_code_grant') !!}"
})
Copy link
Owner

Choose a reason for hiding this comment

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

Should we wrap this with if:

Suggested change
ui.initOAuth({
usePkceWithAuthorizationCodeGrant: "{!! (bool)config('l5-swagger.defaults.ui.authorization.use_pkce_with_authorization_code_grant') !!}"
})
@if((bool)config('l5-swagger.defaults.ui.authorization.use_pkce_with_authorization_code_grant'))
ui.initOAuth({
usePkceWithAuthorizationCodeGrant: "{!! (bool)config('l5-swagger.defaults.ui.authorization.use_pkce_with_authorization_code_grant') !!}"
})
@endif

Or this call ui.initOAuth will not change default behaviour if we are not using oAuth?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, I suggest checking that at least one of the security schemes type is oauth2. Only with this condition we add ui.initOauth. Besides that, I moved option use_pkce_with_authorization_code_grant to new oauth2 array element, I think in such way it is more readable.
Please, see details in my latest commit.

@DarkaOnLine DarkaOnLine merged commit 64d820b into DarkaOnLine:master Aug 5, 2022
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