8000 Supporting OAuth 2.1 for public clients by tnorimat · Pull Request #27176 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Supporting OAuth 2.1 for public clients - #27176

Merged
mposolda merged 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-25316-OAuth-2-1-Public-Clien
Feb 22, 2024
Merged

mposolda merged 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-25316-OAuth-2-1-Public-Clien

Conversation

@tnorimat
Copy link
Copy Markdown
Contributor

closes #25316

@tnorimat
Copy link
Copy Markdown
Contributor Author

@mposolda I added tests and documentation. Could you check the PR?

@tnorimat
tnorimat force-pushed the ISSUE-25316-OAuth-2-1-Public-Clien branch from 244706a to 361cdec Compare February 20, 2024 19:34
@tnorimat
Copy link
Copy Markdown
Contributor Author

@mposolda I forgotten that DPoP is still a preview feature so that we cannot include its executor into a default profile until DPoP get out of a preview feature.
One option is that we would wait for completing #22311 . After that, this PR would be merged.
The other option is that this PR would exclude DPoP enforcer executor and a follow-up PR includes it after #22311 .

Do you think which would be a good option?

@mposolda
Copy link
Copy Markdown
Contributor

@mposolda I forgotten that DPoP is still a preview feature so that we cannot include its executor into a default profile until DPoP get out of a preview feature. One option is that we would wait for completing #22311 . After that, this PR would be merged. The other option is that this PR would exclude DPoP enforcer executor and a follow-up PR includes it after #22311 .

Do you think which would be a good option?

I am not sure when DPoP feature is promoted from preview...

Another option might be to use configuration including DPoP executor, but add something into the DPoP executor itself (instead of implementing EnvironmentDependentFactory). Perhaps something like:

If (Profile.isFeatureEnabled(DPOP) {
   executeChecksImpl(); // execute checks as done today
} else {
   logger.warnf("DPoP executor is used, but DPOP feature is not enabled. So DPOP is not enforced for the clients. Please enable DPOP feature in order to be able to have DPOP checks applied");
}

This way the configuration will work OOTB, but dpop checks just won't be done in runtime and instead warning would be shown if someone want to use oauth 2.1 client profile for public clients. WDYT?

@mposolda
Copy link
Copy Markdown
Contributor

@tnorimat I can also add that it can be nice if it is mentioned in the docs that OAuth 2.1 is still draft specification. I've commented in a similar way for your other PR for OAuth 2.1 confidential clients.

@mposolda mposolda self-assigned this Feb 21, 2024
@tnorimat
tnorimat force-pushed the ISSUE-25316-OAuth-2-1-Public-Clien branch 2 times, most recently from 1b61fa4 to eafcc87 Compare February 22, 2024 04:05
@tnorimat
tnorimat commented Feb 22, 2024 •
Copy link
Copy Markdown
Contributor Author

@mposolda I modified DPoPBindEnforcerExecutor and DPoPBindEnforcerExecutorFactory to call Profile.isFeatureEnabled(Feature.DPOP) in DPoPBindEnforcerExecutor and remove EnvironmentDependentFactory from DPoPBindEnforcerExecutorFactory.

    @Override
    public void executeOnEvent(ClientPolicyContext context) throws ClientPolicyException {
        if (!Profile.isFeatureEnabled(Feature.DPOP)) {
            logger.warnf("DPoP executor is used, but DPOP feature is disabled. So DPOP is not enforced for the clients. " +
                    "Please enable DPOP feature in order to be able to have DPOP checks applied.");
            return;
        }

        HttpRequest request = session.getContext().getHttpRequest();
        switch (context.getEvent()) {

Also I modified the documentation as you suggested the same as in the PR for OAuth 2.1 confidential client.

@mposolda
Copy link
Copy Markdown
Contributor

@andymunro Thanks for the review!
@tnorimat Could you please rebase on top of latest main? I think that it will remove some (or all?) of documentation changes in this PR.

@tnorimat
tnorimat force-pushed the ISSUE-25316-OAuth-2-1-Public-Clien branch from eafcc87 to dfdc8f1 Compare February 22, 2024 08:25
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
and link them to the global client profiles for OAuth 2.1 support, which are automatically available in each realm. You can use ether `oauth-2-1-for-confidential-client` profile for confidential clients or `oauth-2-1-for-public-client` profile for public clients.
and link them to the global client profiles for OAuth 2.1 support, which are automatically available in each realm. You can use either `oauth-2-1-for-confidential-client` profile for confidential clients or `oauth-2-1-for-public-client` profile for public clients.

Small typo. Do you please have a chance to fix it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. I fixed it.

@mposolda
mposolda commented Feb 22, 2024 •
Copy link
Copy Markdown
Contributor

@tnorimat Thanks for the updates! Is it also possible to add some small note to the docs, that for OAuth 2.1 with public clients, it is recommended to use DPOP preview feature? Also there is very small typo in the docs (See inline).

closes keycloak#25316

Co-authored-by: shigeyuki kabano <shigeyuki.kabano.sj@hitachi.com>
Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
@tnorimat
tnorimat force-pushed the ISSUE-25316-OAuth-2-1-Public-Clien branch from dfdc8f1 to f414daa Compare February 22, 2024 08:47
@tnorimat
Copy link
Copy Markdown
Contributor Author

@mposolda I added the sentence to recommend using DPoP in oauth21-support.adoc.

NOTE: When using OAuth 2.1 profile for public clients, it is recommended to use DPoP preview feature as described in the link:{adminguide_link}#_dpop-bound-tokens[{adminguide_name}] because DPoP binds an access token and a refresh token together with the public part of a client's key pair. This binding prevents an attacker from using stolen tokens.

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.x509.X509BrowserCRLTest#loginFailedWithIntermediateRevocationListFromHttp

Keycloak CI - FIPS IT (non-strict)

java.lang.RuntimeException: Could not create statement
	at org.jboss.arquillian.junit.Arquillian.methodBlock(Arquillian.java:307)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
...

Report flaky test

org.keycloak.testsuite.x509.X509BrowserCRLTest#loginFailedWithInvalidSignatureCRL

Keycloak CI - FIPS IT (non-strict)

java.lang.RuntimeException: Could not create statement
	at org.jboss.arquillian.junit.Arquillian.methodBlock(Arquillian.java:307)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
...

Report flaky test

@mposolda mposolda left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@tnorimat Thanks!

@mposolda
mposolda merged commit 1e12b15 into keycloak:main Feb 22, 2024
@tnorimat
tnorimat deleted the ISSUE-25316-OAuth-2-1-Public-Clien branch February 22, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supporting OAuth 2.1 for public clients

3 participants

0