-
Notifications
You must be signed in to change notification settings - Fork 43
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
24 changed files
with
770 additions
and
101 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
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
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
package com.getindata.connectors.http.internal; | ||
|
||
import java.net.http.HttpClient; | ||
import java.time.Duration; | ||
import java.util.Optional; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import com.getindata.connectors.http.internal.auth.OidcAccessTokenManager; | ||
|
||
/** | ||
* Header processor for HTTP OIDC Authentication mechanism. | ||
*/ | ||
@Slf4j | ||
public class OIDCAuthHeaderValuePreprocessor implements HeaderValuePreprocessor { | ||
|
||
|
||
private final String oidcAuthURL; | ||
private final String oidcTokenRequest; | ||
private Duration oidcExpiryReduction = Duration.ofSeconds(1); | ||
/** | ||
* 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.get(); | ||
this.oidcTokenRequest = oidcTokenRequest.get(); | ||
if (oidcExpiryReduction.isPresent()) { | ||
this.oidcExpiryReduction = oidcExpiryReduction.get(); | ||
} | ||
} | ||
|
||
@Override | ||
public String preprocessHeaderValue(String rawValue) { | ||
OidcAccessTokenManager auth = new OidcAccessTokenManager( | ||
HttpClient.newBuilder().build(), | ||
oidcTokenRequest, | ||
oidcAuthURL, | ||
oidcExpiryReduction | ||
); | ||
// apply the OIDC authentication by adding the dynamically calculated header value. | ||
return "BEARER " + auth.authenticate(); | ||
} | ||
} |
Oops, something went wrong.