-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: davidradl <[email protected]>
- Loading branch information
Showing
22 changed files
with
728 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
|
||
## [Unreleased] | ||
|
||
### Added | ||
|
||
- Added support for OIDC Bearer tokens. | ||
|
||
## [0.15.0] - 2024-07-30 | ||
|
||
### Added | ||
|
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
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
44 changes: 44 additions & 0 deletions
44
src/main/java/com/getindata/connectors/http/internal/OIDCAuthHeaderValuePreprocessor.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,44 @@ | ||
package com.getindata.connectors.http.internal; | ||
|
||
import java.net.http.HttpClient; | ||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
import com.getindata.connectors.http.internal.auth.OidcAccessTokenManager; | ||
|
||
/** | ||
* Header processor for HTTP OIDC Authentication mechanism. | ||
*/ | ||
public class OIDCAuthHeaderValuePreprocessor implements HeaderValuePreprocessor { | ||
|
||
|
||
private final Optional<String> oidcAuthURL; | ||
private final Optional<String> oidcTokenRequest; | ||
private final Optional<Duration> oidcExpiryReduction; | ||
/** | ||
* Add the access token to the request using OidcAuth authenticate method that | ||
* gives us a valid access token. | ||
* @param oidcAuthURL OIDC token endpoint | ||
* @param oidcTokenRequest OIDC Token Request | ||
* @param oidcExpiryReduction OIDC token expiry reduction | ||
*/ | ||
public OIDCAuthHeaderValuePreprocessor(Optional<String> oidcAuthURL, | ||
Optional<String> oidcTokenRequest, | ||
Optional<Duration> oidcExpiryReduction) { | ||
this.oidcAuthURL = oidcAuthURL; | ||
this.oidcTokenRequest = oidcTokenRequest; | ||
this.oidcExpiryReduction = oidcExpiryReduction; | ||
} | ||
|
||
@Override | ||
public String preprocessHeaderValue(String rawValue) { | ||
OidcAccessTokenManager auth = new OidcAccessTokenManager( | ||
HttpClient.newBuilder().build(), | ||
oidcTokenRequest.get(), | ||
oidcAuthURL.get(), | ||
oidcExpiryReduction.get() | ||
); | ||
// apply the OIDC authentication by adding the dynamically calculated header value. | ||
return "BEARER " + auth.authenticate(); | ||
} | ||
} |
Oops, something went wrong.