Skip to content

Commit

Permalink
docs: update Agama consent docs #10766
Browse files Browse the repository at this point in the history
Signed-off-by: jgomer2001 <[email protected]>
  • Loading branch information
jgomer2001 committed Jan 31, 2025
1 parent 1aa17e9 commit 1e97fed
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/script-catalog/consent_gathering/consent-gathering.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 1e97fed

Please sign in to comment.