From c6e6d52eb5cac73c266b9dc5244d663418a03caf Mon Sep 17 00:00:00 2001 From: Sachin Mamoru <59449070+Sachin-Mamoru@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:22:24 +0530 Subject: [PATCH 1/4] Revert "Revert "[Asgardeo] Update Documentation to Include Usage of Secrets in Conditional Authentication Scripts"" --- .../configure-conditional-auth.md | 12 +- .../conditional-auth/api-reference.md | 126 ++++++++++++++---- 2 files changed, 109 insertions(+), 29 deletions(-) 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 7cddcc03bc..4420d4578f 100644 --- a/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md +++ b/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md @@ -106,4 +106,14 @@ To delete an existing secret: 5. Select the checkbox and confirm your action. -{% endif %} \ No newline at end of file +### Using Secrets in Scripts + +You may refer to the added secrets in your conditional authentication scripts using the `secrets.key` 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. + +{% endif %} diff --git a/en/includes/references/conditional-auth/api-reference.md b/en/includes/references/conditional-auth/api-reference.md index e6f5b59317..7a6c4a0b5c 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 - + - + - - + + - + @@ -904,13 +907,15 @@ 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'); - context.selectedAcr = data.status; + Log.info("Successfully invoked the external API."); executeStep(1); }, onFail: function(context, data) { - Log.info('httpGet call failed'); - context.selectedAcr = 'FAILED'; + Log.info("Error occurred while invoking the external API."); + executeStep(2); + }, + onTimeout: function(context, data) { + Log.info("Invoking external API timed out."); executeStep(2); } }); @@ -965,25 +970,26 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints
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 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.
- + - + - + - - + + - + @@ -1009,13 +1015,15 @@ 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'); - context.selectedAcr = data.status; + Log.info("Successfully invoked the external API."); executeStep(1); }, onFail: function(context, data) { - Log.info('httpPost call failed'); - context.selectedAcr = 'FAILED'; + Log.info("Error occurred while invoking the external API."); + executeStep(2); + }, + onTimeout: function(context, data) { + Log.info("Invoking external API timed out."); executeStep(2); } }); @@ -1332,15 +1340,77 @@ It contains the necessary metadata for invoking the API when calling the callCho
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 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.
-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.key` 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 June 2024" + Starting from 30th June 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
basicauthusername, 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.
bearertokentokenUses 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.key` 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.
From 9acc22f1d66873e2c67cb71939862187674bece9 Mon Sep 17 00:00:00 2001 From: Sachin Mamoru <59449070+Sachin-Mamoru@users.noreply.github.com> Date: Wed, 2 Oct 2024 00:44:45 +0530 Subject: [PATCH 2/4] addressed comments --- .../configure-conditional-auth.md | 20 +++++++++---------- .../conditional-auth/api-reference.md | 14 ++++++++----- 2 files changed, 19 insertions(+), 15 deletions(-) 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 4420d4578f..498c3a52b9 100644 --- a/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md +++ b/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md @@ -79,6 +79,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: @@ -106,14 +116,4 @@ To delete an existing secret: 5. Select the checkbox and confirm your action. -### Using Secrets in Scripts - -You may refer to the added secrets in your conditional authentication scripts using the `secrets.key` 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. - {% endif %} diff --git a/en/includes/references/conditional-auth/api-reference.md b/en/includes/references/conditional-auth/api-reference.md index 7a6c4a0b5c..eaf84c6fc3 100644 --- a/en/includes/references/conditional-auth/api-reference.md +++ b/en/includes/references/conditional-auth/api-reference.md @@ -880,7 +880,7 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a authConfig - An object containing the necessary metadata to invoke the API. See [AuthConfig](#authconfig) for information. + An object containing the necessary authentication metadata to invoke the API. See [AuthConfig](#authconfig) for information. eventHandlers @@ -908,10 +908,12 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a }, authConfig, { onSuccess: function(context, data) { Log.info("Successfully invoked the external API."); + context.selectedAcr = data.status; executeStep(1); }, onFail: function(context, data) { Log.info("Error occurred while invoking the external API."); + context.selectedAcr = 'FAILED'; executeStep(2); }, onTimeout: function(context, data) { @@ -983,7 +985,7 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints authConfig - An object containing the necessary metadata to invoke the API. See [AuthConfig](#authconfig) for more information. + An object containing the necessary authentication metadata to invoke the API. See [AuthConfig](#authconfig) for more information. eventHandlers @@ -1016,10 +1018,12 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints }, authConfig, { onSuccess: function(context, data) { Log.info("Successfully invoked the external API."); + context.selectedAcr = data.status; executeStep(1); }, onFail: function(context, data) { Log.info("Error occurred while invoking the external API."); + context.selectedAcr = 'FAILED'; executeStep(2); }, onTimeout: function(context, data) { @@ -1341,14 +1345,14 @@ It contains the necessary metadata for invoking the API when calling the callCho 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.key` syntax. For example, to retrieve a secret value, you may use: +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 June 2024" +??? note "Change in behavior from 30th September 2024" Starting from 30th June 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. @@ -1399,7 +1403,7 @@ authentication type and its required properties:
-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.key` syntax. For example, to retrieve a secret value, you can use: +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; ``` From 7358dbfc3973b32fffd50084acb2d612f2266c91 Mon Sep 17 00:00:00 2001 From: Sachin Mamoru <59449070+Sachin-Mamoru@users.noreply.github.com> Date: Wed, 2 Oct 2024 01:51:17 +0530 Subject: [PATCH 3/4] minor updates --- .../conditional-auth/api-reference.md | 81 +------------------ 1 file changed, 3 insertions(+), 78 deletions(-) diff --git a/en/includes/references/conditional-auth/api-reference.md b/en/includes/references/conditional-auth/api-reference.md index eaf84c6fc3..a15552306b 100644 --- a/en/includes/references/conditional-auth/api-reference.md +++ b/en/includes/references/conditional-auth/api-reference.md @@ -895,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" @@ -924,43 +924,6 @@ The HTTP GET function enables sending HTTP GET requests to specified endpoints a } ``` -!!! 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.` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)` @@ -1034,44 +997,6 @@ The HTTP POST function enables sending HTTP POST requests to specified endpoints } ``` -!!! 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.` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)` @@ -1381,7 +1306,7 @@ authentication type and its required properties: - basicauth + basic username, password Uses user credentials. @@ -1396,7 +1321,7 @@ authentication type and its required properties: Uses client credentials to obtain an access token. - bearertoken + bearer token Uses a bearer token for authentication. From cc28685065385ccc3454062eccfb6f0d6d5576f9 Mon Sep 17 00:00:00 2001 From: Sachin Mamoru <59449070+Sachin-Mamoru@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:47:19 +0530 Subject: [PATCH 4/4] addressed comments --- .../conditional-auth/configure-conditional-auth.md | 2 +- en/includes/references/conditional-auth/api-reference.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 498c3a52b9..952c84df5b 100644 --- a/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md +++ b/en/includes/guides/authentication/conditional-auth/configure-conditional-auth.md @@ -65,7 +65,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 diff --git a/en/includes/references/conditional-auth/api-reference.md b/en/includes/references/conditional-auth/api-reference.md index a15552306b..70d33ef417 100644 --- a/en/includes/references/conditional-auth/api-reference.md +++ b/en/includes/references/conditional-auth/api-reference.md @@ -1278,7 +1278,7 @@ For more information on adding secrets, refer to the [Add a secret to the script documentation. ??? note "Change in behavior from 30th September 2024" - Starting from 30th June 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. + 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.