public class BrowserIdcAuthPlugin extends CommonCredentialsProvider
| Modifier and Type | Field and Description |
|---|---|
int |
CODE_VERIFIER_BYTE_LENGTH
It is used to set the number of bytes of the code verifier
|
int |
CREATE_TOKEN_POLLING_INTERVAL
The default time in seconds for which the client must wait between attempts when polling for a session
|
int |
DEFAULT_IDC_TOKEN_EXPIRY_IN_SEC
It is used if auth server doesn't provide any value access token expiration
|
protected static Pattern |
IAM_HTTP_URL_PATTERN |
protected static Pattern |
IAM_URL_PATTERN |
static String |
KEY_IDC_REGION
Key for setting IdC region.
|
static String |
KEY_IDC_RESPONSE_TIMEOUT
Key for setting timeout for IDP response.
|
static String |
KEY_ISSUER_URL
Key for setting idp tenant.
|
static String |
KEY_LISTEN_PORT
Key for setting the port number for listening.
|
protected static String |
KEY_SSL_INSECURE |
protected String |
m_idc_region
IdC region variable.
|
protected String |
m_issuer_url
Issuer URL variable.
|
protected RedshiftLogger |
m_log |
protected String |
m_redirect_uri
Redirect URI variable.
|
protected AWSSSOOIDC |
m_sdk_client
AWSSSOOIDC client object needed to SSOOIDC methods
|
protected boolean |
m_sslInsecure |
long |
MILLISECOND_MULTIPLIER
It is used to multiply millisecond values to get seconds
|
static String |
OAUTH_CHALLENGE_METHOD_PARAMETER_NAME
Key for setting code challenge.
|
static String |
OAUTH_CLIENT_ID_PARAMETER_NAME
Key for setting client ID.
|
static String |
OAUTH_CODE_CHALLENGE_PARAMETER_NAME
Key for setting code challenge.
|
static String |
OAUTH_CSRF_STATE_PARAMETER_NAME
Key for setting CSRF endpoint protection state.
|
static String |
OAUTH_GRANT_TYPE_PARAMETER_NAME
Key for setting grant type.
|
static String |
OAUTH_REDIRECT_PARAMETER_NAME
Key for setting redirect URI.
|
static String |
OAUTH_RESPONSE_TYPE_PARAMETER_NAME
Key for setting OAUTH response type.
|
static String |
OAUTH_SCOPE_PARAMETER_NAME
Key for setting scope.
|
m_disableCache| Constructor and Description |
|---|
BrowserIdcAuthPlugin() |
| Modifier and Type | Method and Description |
|---|---|
void |
addParameter(String key,
String value)
Overridden method to grab the field parameters from JDBC connection string or extended params provided by user.
|
protected String |
fetchAuthorizationCode(String codeChallenge,
RegisterClientResult registerClientResult)
Retrieves an IdC vended authorization code from the IdC server through the redirectURI
|
protected CreateTokenResult |
fetchTokenResult(RegisterClientResult registerClientResult,
String authCode,
String codeVerifier)
Creates and returns an access token for the authorized client within if successful before the timeout
|
protected String |
generateCodeChallenge(String verifier)
Applies a SHA256 hash to the code verifier
|
protected String |
generateCodeVerifier()
Generates a high entropy random codeVerifier string that will be used in the PKCE flow
|
protected NativeTokenHolder |
getAuthToken()
Overridden method to obtain the auth token from plugin specific implementation
|
protected CreateTokenResult |
getCreateTokenResult(String clientId,
String clientSecret,
String authCode,
String grantType,
String codeVerifier,
String redirectUri)
Creates and returns an access token for the authorized client.
|
protected CloseableHttpClient |
getHttpClient() |
protected NativeTokenHolder |
getIdcToken()
Returns the retrieved access token from IdC authorization server
|
protected static String |
getRegexForJsonKey(String keyName) |
protected RegisterClientResult |
getRegisterClientResult()
Registers a client with IAM Identity Center.
|
protected void |
openBrowser(String state,
String codeChallenge,
RegisterClientResult registerClientResult)
Opens the default browser with the authorization code request to IdC /authorize endpoint
|
protected NativeTokenHolder |
processCreateTokenResult(CreateTokenResult createTokenResult)
Takes a created token result as input and returns an object of type NativeTokenHolder that contains the access token and expiration
|
protected void |
validateURL(String paramString) |
getCacheKey, getCredentials, getIdpToken, getPluginSpecificCacheKey, refresh, setLoggerpublic static final String KEY_IDC_RESPONSE_TIMEOUT
public static final String KEY_LISTEN_PORT
public static final String KEY_ISSUER_URL
public static final String KEY_IDC_REGION
public static final String OAUTH_CSRF_STATE_PARAMETER_NAME
public static final String OAUTH_REDIRECT_PARAMETER_NAME
public static final String OAUTH_CLIENT_ID_PARAMETER_NAME
public static final String OAUTH_RESPONSE_TYPE_PARAMETER_NAME
public static final String OAUTH_GRANT_TYPE_PARAMETER_NAME
public static final String OAUTH_SCOPE_PARAMETER_NAME
public static final String OAUTH_CODE_CHALLENGE_PARAMETER_NAME
public static final String OAUTH_CHALLENGE_METHOD_PARAMETER_NAME
public final int CREATE_TOKEN_POLLING_INTERVAL
public final int DEFAULT_IDC_TOKEN_EXPIRY_IN_SEC
public final int CODE_VERIFIER_BYTE_LENGTH
public final long MILLISECOND_MULTIPLIER
protected String m_issuer_url
protected String m_idc_region
protected String m_redirect_uri
protected AWSSSOOIDC m_sdk_client
protected static final String KEY_SSL_INSECURE
protected boolean m_sslInsecure
protected static final Pattern IAM_URL_PATTERN
protected static final Pattern IAM_HTTP_URL_PATTERN
protected RedshiftLogger m_log
protected NativeTokenHolder getAuthToken() throws IOException
getAuthToken in class CommonCredentialsProviderNativeTokenHolder A wrapper containing auth token and its expiration time informationIOException - indicating the errorprotected NativeTokenHolder getIdcToken() throws IOException
NativeTokenHolder This contains the retrieved access token and the expiration time of that tokenIOException - if an error occurs during the involved API callpublic void addParameter(String key, String value)
addParameter in interface INativePluginaddParameter in class CommonCredentialsProviderkey - parameter key passed to JDBC drivervalue - parameter value associated with the given keyprotected RegisterClientResult getRegisterClientResult()
throws IOException
RegisterClientResult Client registration result containing clientId and clientSecret required for authorization code + PKCE flowIOException - if an error occurs during the involved API callprotected String generateCodeVerifier()
protected String generateCodeChallenge(String verifier)
verifier - Randomly generated base64 encoded stringprotected String fetchAuthorizationCode(String codeChallenge, RegisterClientResult registerClientResult) throws IOException, URISyntaxException
codeChallenge - String generated from applying a SHA256 hash to the code verifierregisterClientResult - Contains the clientId and clientSecretString authCode: Authorization code returned from the IdC authorization server used to get the access tokenIOException - If an I/O error occurs while communicating with the IdC server or processing the responseURISyntaxException - If the redirect URI or any other URI involved in the authorization process is malformed or violates URI syntax rulesprotected CreateTokenResult fetchTokenResult(RegisterClientResult registerClientResult,
String authCode,
String codeVerifier)
throws IOException
registerClientResult - Contains the clientId and clientSecretauthCode - Authorization code returned from the IdC authorization server used to get the access tokencodeVerifier - Randomly generated base64 encoded 60 byte stringCreateTokenResult Create token result containing IdC tokenIOException - If an I/O error occurs while communicating with the IdC server or processing the responseprotected CreateTokenResult getCreateTokenResult(String clientId, String clientSecret, String authCode, String grantType, String codeVerifier, String redirectUri)
clientId - The unique identifier string for each clientclientSecret - A secret string generated for the clientauthCode - Authorization code used to get the access tokengrantType - Supports grant types for the authorization code requestcodeVerifier - Used for PKCE flowredirectUri - Used to verify that the redirectUri is the sameCreateTokenResult Create token result containing IdC tokenprotected NativeTokenHolder processCreateTokenResult(CreateTokenResult createTokenResult) throws IOException
createTokenResult - Contains the access token, refresh token, and accces token expiryNativeTokenHolder This contains the retrieved access token and the expiration time of that tokenIOException - If an I/O error occurs while communicating with the IdC server or processing the responseprotected void openBrowser(String state, String codeChallenge, RegisterClientResult registerClientResult) throws URISyntaxException, IOException
state - A randomly generated string to protect against cross-site request forgery attackscodeChallenge - String generated from applying a SHA256 hash to the code verifierregisterClientResult - Contains the clientId and clientSecretIOException - If an error occurs while opening the default browser or establishing a connection to the IdC /authorize endpointURISyntaxException - If the URI used for the authorization code request is malformed or violates URI syntax rulesprotected CloseableHttpClient getHttpClient()
throws GeneralSecurityException
GeneralSecurityExceptionprotected void validateURL(String paramString) throws IOException
IOExceptionCopyright © 2024 Amazon.com Inc.. All rights reserved.