diff --git a/docs/script-catalog/consent_gathering/consent-gathering.md b/docs/script-catalog/consent_gathering/consent-gathering.md index 6021561097a..5b6558197f7 100644 --- a/docs/script-catalog/consent_gathering/consent-gathering.md +++ b/docs/script-catalog/consent_gathering/consent-gathering.md @@ -262,3 +262,32 @@ This is how consent will work depending on the authentication request issued: - With `agama_co.acme.mysuperflow`, the Agama flow `io.jans.consent.B` will be launched for consent Agama flows used for consent can be built using the same approach and tooling used for regular authentication flows. Note however there is no need to pass a user identity in the `Finish` instruction. If passed, it will be ignored, thus, it suffices to end a consent flow with `Finish false/true`. + +### Getting contextual data + +To access information in your Agama consent flow related to the user attempting login, scopes requested, etc., get an instance of managed bean `io.jans.as.server.util.AgamaConsentUtil` and use the available methods as summarized below: + +|Method|Description|Reference class| +|-|-|-| +|`getClient`|Gets a reference to the OAuth client associated to the authentication request|[Client](https://github.com/JanssenProject/jans/tree/vreplace-janssen-version/jans-auth-server/common/src/main/java/io/jans/as/common/model/registration/Client.java)| +|`getScopes`|A list of OAuth scopes requested|[Scope](https://github.com/JanssenProject/jans/tree/vreplace-janssen-version/jans-auth-server/persistence-model/src/main/java/io/jans/as/persistence/model/Scope.java)| +|`getUser`|A reference to the user attempting authentication|[User](https://github.com/JanssenProject/jans/tree/vreplace-janssen-version/jans-auth-server/common/src/main/java/io/jans/as/common/model/common/User.java) / [SimpleUser](https://github.com/JanssenProject/jans/tree/vreplace-janssen-version/jans-core/model/src/main/java/io/jans/model/user/SimpleUser.java)| +|`getSessionAttributes`|A map containing the parameters of the OAuth authentication request issued|| + +Java example code: + +``` +import io.jans.as.server.util.AgamaConsentUtil; +import io.jans.service.cdi.util.CdiUtil; +... +AgamaConsentUtil acu = CdiUtil.bean(AgamaConsentUtil.class); +String name = acu.getClient().getClientName(); //retrieves the client's display name +``` + +Agama DSL example: + +``` +acuCls = Call io.jans.as.server.util.AgamaConsentUtil#class +acu = Call io.jans.service.cdi.util.CdiUtil#bean acuCls +name = acu.client.clientName //retrieves the client's display name +```