forked from OpenLiberty/open-liberty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 21826: Add prototype code for creating private_key_jwt client a…
…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
- Loading branch information
Showing
12 changed files
with
352 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...mmon/src/com/ibm/ws/security/openidconnect/common/token/auth/PrivateKeyJwtAuthMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package com.ibm.ws.security.openidconnect.common.token.auth; | ||
|
||
import java.security.Key; | ||
|
||
import com.ibm.ws.security.openidconnect.clients.common.ConvergedClientConfig; | ||
|
||
import io.openliberty.security.oidcclientcore.token.TokenRequestor.Builder; | ||
|
||
public class PrivateKeyJwtAuthMethod extends TokenEndpointAuthMethod { | ||
|
||
public static final String AUTH_METHOD = "private_key_jwt"; | ||
|
||
private final ConvergedClientConfig clientConfig; | ||
|
||
public PrivateKeyJwtAuthMethod(ConvergedClientConfig clientConfig) { | ||
this.clientConfig = clientConfig; | ||
} | ||
|
||
@Override | ||
public void setAuthMethodSpecificSettings(Builder tokenRequestBuilder) { | ||
tokenRequestBuilder.clientAssertionSigningAlgorithm(clientConfig.getTokenEndpointAuthSigningAlgorithm()); | ||
Key clientAssertionSigningKey = getKeyForPrivateKeyJwtClientAssertion(); | ||
tokenRequestBuilder.clientAssertionSigningKey(clientAssertionSigningKey); | ||
} | ||
|
||
private Key getKeyForPrivateKeyJwtClientAssertion() { | ||
// TODO | ||
return null; | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...mmon/src/com/ibm/ws/security/openidconnect/common/token/auth/TokenEndpointAuthMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package com.ibm.ws.security.openidconnect.common.token.auth; | ||
|
||
import com.ibm.ws.security.openidconnect.clients.common.ConvergedClientConfig; | ||
|
||
import io.openliberty.security.oidcclientcore.token.TokenRequestor.Builder; | ||
|
||
public abstract class TokenEndpointAuthMethod { | ||
|
||
public static TokenEndpointAuthMethod getInstance(String authMethod, ConvergedClientConfig clientConfig) { | ||
if (authMethod == null || authMethod.isEmpty()) { | ||
return null; | ||
} | ||
if (PrivateKeyJwtAuthMethod.AUTH_METHOD.equals(authMethod)) { | ||
return new PrivateKeyJwtAuthMethod(clientConfig); | ||
} | ||
return null; | ||
} | ||
|
||
public abstract void setAuthMethodSpecificSettings(Builder tokenRequestBuilder); | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
....clients.common/src/com/ibm/ws/security/openidconnect/common/token/auth/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
/** | ||
* @version 1.0 | ||
*/ | ||
@org.osgi.annotation.versioning.Version("1.0") | ||
@TraceOptions(traceGroup = TraceConstants.TRACE_GROUP, messageBundle = TraceConstants.MESSAGE_BUNDLE) | ||
package com.ibm.ws.security.openidconnect.common.token.auth; | ||
|
||
import com.ibm.websphere.ras.annotation.TraceOptions; | ||
import com.ibm.ws.security.openidconnect.common.TraceConstants; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...nal/src/io/openliberty/security/oidcclientcore/exceptions/PrivateKeyJwtAuthException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.security.oidcclientcore.exceptions; | ||
|
||
import com.ibm.websphere.ras.Tr; | ||
import com.ibm.websphere.ras.TraceComponent; | ||
|
||
public class PrivateKeyJwtAuthException extends Exception { | ||
|
||
public static final TraceComponent tc = Tr.register(PrivateKeyJwtAuthException.class); | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final String clientId; | ||
private final String nlsMessage; | ||
|
||
public PrivateKeyJwtAuthException(String clientId, String nlsMessage) { | ||
this.clientId = clientId; | ||
this.nlsMessage = nlsMessage; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return Tr.formatMessage(tc, "PRIVATE_KEY_JWT_AUTH_ERROR", clientId, nlsMessage); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
.../openliberty/security/oidcclientcore/exceptions/PrivateKeyJwtAuthMissingKeyException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package io.openliberty.security.oidcclientcore.exceptions; | ||
|
||
import com.ibm.websphere.ras.Tr; | ||
import com.ibm.websphere.ras.TraceComponent; | ||
|
||
public class PrivateKeyJwtAuthMissingKeyException extends Exception { | ||
|
||
public static final TraceComponent tc = Tr.register(PrivateKeyJwtAuthMissingKeyException.class); | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private final String clientId; | ||
|
||
public PrivateKeyJwtAuthMissingKeyException(String clientId) { | ||
this.clientId = clientId; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return Tr.formatMessage(tc, "PRIVATE_KEY_JWT_MISSING_SIGNING_KEY", clientId); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.