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

Issue 21826: Add prototype code for creating private_key_jwt client authentication #25133

Merged
merged 4 commits into from
May 1, 2023

Conversation

ayoho
Copy link
Member

@ayoho ayoho commented Apr 27, 2023

  • Adds logic to the OIDC token endpoint request code to add private_key_jwt related parameters when using that token endpoint auth method

  • Adds a large part of the logic to the PrivateKeyJwtAuthMethod class to create the JWT for client authentication

  • Adds logic for retrieving the private key to use from the configured keystore.

    For OIDC client certificate support  #21826

…uthentication

- Adds logic to the OIDC token endpoint request code to add `private_key_jwt` related parameters when using that token endpoint auth method
- Adds a large part of the logic to the `PrivateKeyJwtAuthMethod` class to create the JWT for client authentication
    - Note: Still missing logic to obtain the key itself using the keyAliasName

For OpenLiberty#21826
Had to move some classes around to avoid the following:

```
[ERROR   ] CWWKE0702E: Could not resolve module: com.ibm.ws.security.openidconnect.common [149]
  Bundle was not resolved because of a uses constraint violation.
  org.apache.felix.resolver.reason.ReasonException: Uses constraint violation. Unable to resolve resource com.ibm.ws.security.openidconnect.common [osgi.identity; osgi.identity="com.ibm.ws.security.openidconnect.common"; type="osgi.bundle"; version:Version="1.0.77.202304261135"] because it exports package 'com.ibm.ws.security.openidconnect.common' and is also exposed to it from resource com.ibm.ws.security.openidconnect.clients.common [osgi.identity; osgi.identity="com.ibm.ws.security.openidconnect.clients.common"; type="osgi.bundle"; version:Version="1.0.77.202304261135"] via the following dependency chain:
```

My guess is that opening up the `com.ibm.ws.security.openidconnect.clients.common` bundle that had its own `com.ibm.ws.security.openidconnect.common` package conflicted with the actual `com.ibm.ws.security.openidconnect.common` project.
Adds logic for retrieving the private key to use from the configured keystore.

For OpenLiberty#21826
@ayoho ayoho self-assigned this Apr 27, 2023
@ayoho
Copy link
Member Author

ayoho commented Apr 27, 2023

jimmy1wu
jimmy1wu previously approved these changes Apr 28, 2023
Copy link

@helyarp helyarp left a comment

Choose a reason for hiding this comment

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

Suggested changes

TOKEN_ENDPOINT_AUTH_METHOD_SETTINGS_ERROR.explanation=The OpenID Connect token endpoint requires client authentication, but the OpenID Connect client might be missing information, or the client encountered another error while setting up the authentication data.
TOKEN_ENDPOINT_AUTH_METHOD_SETTINGS_ERROR.useraction=See the error in the message for more information.

PRIVATE_KEY_JWT_MISSING_KEY_ALIAS_NAME=CWWKS1555E: The [{0}] OpenID Connect client does not have a key alias name configured, so the client cannot locate the key to use to sign the JSON Web Token that is used for client authentication.
Copy link

Choose a reason for hiding this comment

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

Remove "that is used" unless it will make the message technically incorrect

TOKEN_ENDPOINT_AUTH_METHOD_SETTINGS_ERROR.useraction=See the error in the message for more information.

PRIVATE_KEY_JWT_MISSING_KEY_ALIAS_NAME=CWWKS1555E: The [{0}] OpenID Connect client does not have a key alias name configured, so the client cannot locate the key to use to sign the JSON Web Token that is used for client authentication.
PRIVATE_KEY_JWT_MISSING_KEY_ALIAS_NAME.explanation=The OpenID Connect client must configure a key alias name to define what key to use to sign the JWT.
Copy link

Choose a reason for hiding this comment

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

Maybe change "what" to "the"

PRIVATE_KEY_JWT_MISSING_KEY_ALIAS_NAME.explanation=The OpenID Connect client must configure a key alias name to define what key to use to sign the JWT.
PRIVATE_KEY_JWT_MISSING_KEY_ALIAS_NAME.useraction=Verify that the OpenID Connect client has a key alias name configured.

PRIVATE_KEY_JWT_MISSING_KEYSTORE_REF=CWWKS1556E: The [{0}] OpenID Connect client does not have a keystore reference configured, so the client cannot locate the key to use to sign the JSON Web Token that is used for client authentication.
Copy link

Choose a reason for hiding this comment

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

Remove "that is used"

PRIVATE_KEY_JWT_AUTH_ERROR.explanation=The OpenID Connect client is configured to use JSON Web Tokens for client authentication, but an error occurred while creating the token.
PRIVATE_KEY_JWT_AUTH_ERROR.useraction=For more information, see the error in the message.

PRIVATE_KEY_JWT_MISSING_SIGNING_KEY=CWWKS2431E: The [{0}] OpenID Connect client is missing the key that is needed to sign the token that is used for client authentication.
Copy link

Choose a reason for hiding this comment

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

Remove "that is used" unless it will make the message technically incorrect

PRIVATE_KEY_JWT_AUTH_ERROR.useraction=For more information, see the error in the message.

PRIVATE_KEY_JWT_MISSING_SIGNING_KEY=CWWKS2431E: The [{0}] OpenID Connect client is missing the key that is needed to sign the token that is used for client authentication.
PRIVATE_KEY_JWT_MISSING_SIGNING_KEY.explanation=The OpenID Connect client configuration is missing data, or a key cannot be found with the key alias name in the SSL configuration that is specified in the OpenID Connect client.
Copy link

Choose a reason for hiding this comment

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

Change "that is specified in" to "for"


PRIVATE_KEY_JWT_MISSING_SIGNING_KEY=CWWKS2431E: The [{0}] OpenID Connect client is missing the key that is needed to sign the token that is used for client authentication.
PRIVATE_KEY_JWT_MISSING_SIGNING_KEY.explanation=The OpenID Connect client configuration is missing data, or a key cannot be found with the key alias name in the SSL configuration that is specified in the OpenID Connect client.
PRIVATE_KEY_JWT_MISSING_SIGNING_KEY.useraction=Ensure that the OpenID Connect client has a key alias name and SSL reference configured. Verify that the keystore that is referenced by the SSL configuration contains a key whose alias matches the key alias name in the OpenID Connect client configuration.
Copy link

Choose a reason for hiding this comment

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

Change "that is referenced by the SSL configuration contains" to "that the SSL configuration references contains"

@ayoho
Copy link
Member Author

ayoho commented May 1, 2023

#libby

@LibbyBot
Copy link

LibbyBot commented May 1, 2023

Code analysis and actions

DO NOT DELETE THIS COMMENT.
  • 45 product code files were changed.

  • Please describe in a separate comment how you tested your changes.

  • 1 FAT files were changed, added, or removed.

  • Check that the build did not break the affected FAT suite(s).

  • 3 messages files were changed and need an L2 review.

  • @OpenLiberty/message-reviewer Please review.

  • dev/com.ibm.ws.security.openidconnect.client/resources/com/ibm/ws/security/openidconnect/client/internal/resources/OidcClientMessages.nlsprops

  • dev/io.openliberty.security.oidcclientcore.internal/resources/io/openliberty/security/oidcclientcore/internal/resources/OidcClientCoreMessages.nlsprops

  • dev/com.ibm.ws.security.openidconnect.clients.common/resources/com/ibm/ws/security/openidconnect/clients/common/resources/OidcClientMessages.nlsprops

  • 3 NLS files were changed and need an ID review.

  • @OpenLiberty/message-reviewer Please review.

  • dev/com.ibm.ws.security.openidconnect.client/resources/com/ibm/ws/security/openidconnect/client/internal/resources/OidcClientMessages.nlsprops

  • dev/io.openliberty.security.oidcclientcore.internal/resources/io/openliberty/security/oidcclientcore/internal/resources/OidcClientCoreMessages.nlsprops

  • dev/com.ibm.ws.security.openidconnect.clients.common/resources/com/ibm/ws/security/openidconnect/clients/common/resources/OidcClientMessages.nlsprops

@ayoho ayoho merged commit fa207a8 into OpenLiberty:integration May 1, 2023
@ayoho ayoho deleted the 21826-oidcPrivateKeyJwt-4 branch May 1, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants