diff --git a/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md b/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md index 016f4faaf6..b0c78eae9a 100644 --- a/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md +++ b/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md @@ -69,7 +69,7 @@ To add a new secret: Secret Name - A meaningful name for the secret. This name is not changeable. + A meaningful name for the secret. This name is not changeable and will be used in the script to reference the secret. Secret Value @@ -83,6 +83,16 @@ To add a new secret: 6. Click **Finish** to complete the creation. +### Use secret in the script + +You may refer to the previously added secrets in your conditional authentication scripts using the `secrets.{secret name}` syntax. For example, to retrieve a secret value, you may use: + +```angular2html +var secretValue = secrets.secretName; +``` + +This allows you to securely access secret values within your authentication scripts, enhancing the security and flexibility of your authentication process. + ### Delete an existing secret To delete an existing secret: diff --git a/en/includes/references/conditional-auth/api-reference.md b/en/includes/references/conditional-auth/api-reference.md index e6f5b59317..70d33ef417 100644 --- a/en/includes/references/conditional-auth/api-reference.md +++ b/en/includes/references/conditional-auth/api-reference.md @@ -39,6 +39,7 @@ - [`application`](#application) - [`userAgent`](#user-agent) - [`connectionMetadata`](#connectionmetadata) + - [`authConfig`](#authconfig) --- @@ -88,7 +89,9 @@ This method accepts an object as a parameter and should include the details list <eventCallbacks> (optional) The object that contains the callback functions, which are to be called based on the result of the step execution.
- Supported results are onSuccess and onFail, which can have their own optional callbacks as anonymous functions. + Supported results are onSuccess and onFail which can + have their own optional callbacks as anonymous functions. For these callbacks, the [context](#context) and [data](#data) parameters are passed. + @@ -868,19 +871,19 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a - + - + - - + + - + @@ -892,7 +895,7 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a ``` var authConfig = { - type: "basicauth", + type: "basic", properties: { username: "admin", password: "adminPassword" @@ -904,56 +907,23 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a "Accept": "application/json" }, authConfig, { onSuccess: function(context, data) { - Log.info('httpGet call succeeded'); + Log.info("Successfully invoked the external API."); context.selectedAcr = data.status; executeStep(1); }, onFail: function(context, data) { - Log.info('httpGet call failed'); + Log.info("Error occurred while invoking the external API."); context.selectedAcr = 'FAILED'; executeStep(2); + }, + onTimeout: function(context, data) { + Log.info("Invoking external API timed out."); + executeStep(2); } }); } ``` -!!! note "Authentication Types and Properties" - - When using httpGet functions in Asgardeo adaptive authentication scripts, the table summarizes each authentication type and its required properties: - `Enhanced secret management features are currently under development and will be available soon.` - -
urlurl The URL of the endpoint to which the HTTP GET request should be sent.
headersheaders HTTP request headers to be included in the GET request (optional).
authConfigAuthentication configuration to be included in the GET request (optional).authConfigAn object containing the necessary authentication metadata to invoke the API. See [AuthConfig](#authconfig) for information.
eventHandlerseventHandlers The object that contains the callback functions, which are to be called based on the result of the GET request.
Supported results are onSuccess and onFail, which can have their own optional callbacks as anonymous functions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Authentication TypePropertiesDescription
basicauthusername, passwordUses user credentials.
apikeyapiKey, headerNameUses an API key sent as a header.
clientcredentialconsumerKey, consumerSecret, tokenEndpoint, scope (optional)Uses client credentials to obtain an access token.
bearertokentokenUses a bearer token for authentication.
- ### HTTP POST `httpPost(url, body, headers, authConfig, eventHandlers)` @@ -965,25 +935,26 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints - + - + - + - - + + - + @@ -1009,57 +980,23 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints "Accept": "application/json" }, authConfig, { onSuccess: function(context, data) { - Log.info('httpPost call succeeded'); + Log.info("Successfully invoked the external API."); context.selectedAcr = data.status; executeStep(1); }, onFail: function(context, data) { - Log.info('httpPost call failed'); + Log.info("Error occurred while invoking the external API."); context.selectedAcr = 'FAILED'; executeStep(2); + }, + onTimeout: function(context, data) { + Log.info("Invoking external API timed out."); + executeStep(2); } }); } ``` -!!! note "Authentication Types and Properties" - - When using httpPost functions in Asgardeo adaptive authentication scripts, the table summarizes each authentication type and its required properties: - `Enhanced secret management features are currently under development and will be available soon.` - -
urlurl The URL of the endpoint to which the HTTP POST request should be sent.
bodybody HTTP request body to be included in the POST request.
headersheaders HTTP request headers to be included in the POST request (optional).
authConfigAuthentication configuration to be included in the GET request (optional).authConfigAn object containing the necessary authentication metadata to invoke the API. See [AuthConfig](#authconfig) for more information.
eventHandlerseventHandlers The object that contains the callback functions, which are to be called based on the result of the GET request.
- Supported results are onSuccess and onFail, which can have their own optional callbacks as anonymous functions. + Supported results are onSuccess, onFail and onTimeout which can + have their own optional callbacks as anonymous functions. For these callbacks, the [context](#context) and [data](#data) parameters are passed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Authentication TypePropertiesDescription
basicauthusername, passwordUses user credentials.
apikeyapiKey, headerNameUses an API key sent as a header.
clientcredentialconsumerKey, consumerSecret, tokenEndpoint, scope (optional)Uses client credentials to obtain an access token.
bearertokentokenUses a bearer token for authentication.
- - ### Resolve multi attribute login identifier `resolveMultiAttributeLoginIdentifier(loginIdentifier, tenantDomain)` @@ -1332,15 +1269,77 @@ It contains the necessary metadata for invoking the API when calling the callCho -If the consumer key and the consumer secret are added as secrets, they should be included in the ConnectionMetadata as aliases, as shown below. +You can securely store consumer keys and secrets as **secrets** in conditional authentication scripts and refer to +them in your conditional authentication scripts using the `secrets.{secret name}` syntax. For example, to retrieve a secret value, you may use: +```angular2html +var consumerSecret = secrets.clientSecret; +``` +For more information on adding secrets, refer to the [Add a secret to the script]({{base_path}}/guides/authentication/conditional-auth/configure-conditional-auth/#add-a-secret-to-the-script) section in the +documentation. + +??? note "Change in behavior from 30th September 2024" + Starting from 30th September 2024, you are no longer required to set the aliases for consumer keys and consumer secrets when calling the callChoreo command. Instead, you may directly reference them using the `secrets.secretName` notation. + However, if you prefer, you may continue using the previous method as follows. + + + + + + + + + +
connectionMetadata.consumerKeyAliasThe name of the secret that stores the consumer key.
connectionMetadata.consumerSecretAliasThe name of the secret that stores the consumer secret.
+ +### AuthConfig + +When using httpGet or httpPost functions in Asgardeo adaptive authentication scripts, the table summarizes each +authentication type and its required properties: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Authentication TypePropertiesDescription
basicusername, passwordUses user credentials.
apikeyapiKey, headerNameUses an API key sent as a header.
clientcredentialconsumerKey, consumerSecret, tokenEndpoint, scope (optional, a space separated list of scopes)Uses client credentials to obtain an access token.
bearertokenUses a bearer token for authentication.
+ +You can securely store sensitive values of properties like username, password, consumerKey, consumerSecret as secrets in conditional authentication scripts and refer to them in your conditional authentication scripts using the `secrets.{secret name}` syntax. For example, to retrieve a secret value, you can use: +```angular2html +var consumerSecret = secrets.clientSecret; +``` + +For more information on adding secrets, refer to the [Add a secret to the script]({{base_path}}/guides/authentication/conditional-auth/configure-conditional-auth/#add-a-secret-to-the-script) section in the documentation. + +### Data - - - - - - + +
connectionMetadata.consumerKeyAliasThe name of the secret that stores the consumer key.
connectionMetadata.consumerSecretAliasThe name of the secret that stores the consumer secret.dataThe response data is a JSON object that contains the response data from the API call.