-
Notifications
You must be signed in to change notification settings - Fork 24
Add dest_app_name, dest_app_id, display_username, max_age and prompt #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AaronAtDuo
merged 4 commits into
duosecurity:main
from
scweber-cisco:dest-app-and-display-username
Sep 8, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a8ff6f3
Add dest_app_name, dest_app_id and display_username
scweber-cisco 44267e7
Map auth_context.application.destination_name
scweber-cisco 0813b4a
Add max_age and prompt authorize parameters
scweber-cisco 037b091
Make prompt an enum and trim ApplicationTest
scweber-cisco File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
206 changes: 206 additions & 0 deletions
206
duo-universal-sdk/src/main/java/com/duosecurity/AuthUrlOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,206 @@ | ||
| package com.duosecurity; | ||
|
|
||
| /** | ||
| * The set of values that describe a single authorization request. | ||
| * | ||
| * <p>Instances are created with {@link AuthUrlOptions.Builder} and passed to | ||
| * {@link Client#createAuthUrl(AuthUrlOptions)}. | ||
| */ | ||
| public class AuthUrlOptions { | ||
|
|
||
| /** | ||
| * The values Duo accepts for {@link Builder#setPrompt(Prompt)}. | ||
| */ | ||
| public enum Prompt { | ||
| /** | ||
| * Force the user to authenticate interactively even when a remembered session exists. | ||
| */ | ||
| LOGIN("login"); | ||
|
|
||
| private final String value; | ||
|
|
||
| Prompt(String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| /** | ||
| * The value Duo expects on the wire, which is not the name of the constant. | ||
| * | ||
| * @return the prompt value sent to Duo | ||
| */ | ||
| public String getValue() { | ||
| return value; | ||
| } | ||
| } | ||
|
|
||
| private final String username; | ||
| private final String state; | ||
| private final String nonce; | ||
| private final String destAppName; | ||
| private final String destAppId; | ||
| private final String displayUsername; | ||
| private final Integer maxAge; | ||
| private final Prompt prompt; | ||
|
|
||
| private AuthUrlOptions(Builder builder) { | ||
| this.username = builder.username; | ||
| this.state = builder.state; | ||
| this.nonce = builder.nonce; | ||
| this.destAppName = builder.destAppName; | ||
| this.destAppId = builder.destAppId; | ||
| this.displayUsername = builder.displayUsername; | ||
| this.maxAge = builder.maxAge; | ||
| this.prompt = builder.prompt; | ||
| } | ||
|
|
||
| public String getUsername() { | ||
| return username; | ||
| } | ||
|
|
||
| public String getState() { | ||
| return state; | ||
| } | ||
|
|
||
| public String getNonce() { | ||
| return nonce; | ||
| } | ||
|
|
||
| public String getDestAppName() { | ||
| return destAppName; | ||
| } | ||
|
|
||
| public String getDestAppId() { | ||
| return destAppId; | ||
| } | ||
|
|
||
| public String getDisplayUsername() { | ||
| return displayUsername; | ||
| } | ||
|
|
||
| public Integer getMaxAge() { | ||
| return maxAge; | ||
| } | ||
|
|
||
| public Prompt getPrompt() { | ||
| return prompt; | ||
| } | ||
|
|
||
| /** | ||
| * Builds an {@link AuthUrlOptions}. | ||
| */ | ||
| public static class Builder { | ||
| private final String username; | ||
| private final String state; | ||
| private String nonce; | ||
| private String destAppName; | ||
| private String destAppId; | ||
| private String displayUsername; | ||
| private Integer maxAge; | ||
| private Prompt prompt; | ||
|
|
||
| /** | ||
| * Builder. | ||
| * | ||
| * @param username The user to be authenticated by Duo. | ||
| * @param state A randomly generated String of 16 to 1024 characters. This value will be | ||
| * returned to the integration post 2FA and should be validated. | ||
| * {@link Client#generateState} exists as a utility function to generate it. | ||
| */ | ||
| public Builder(String username, String state) { | ||
| this.username = username; | ||
| this.state = state; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally bind the resulting ID token to this authorization request with a nonce. | ||
| * The same value must be passed to | ||
| * {@link Client#exchangeAuthorizationCodeFor2FAResult(String, String, String)}, which will | ||
| * reject an ID token that does not carry it. | ||
| * | ||
| * @param nonce A randomly generated String of 16 to 1024 characters | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setNonce(String nonce) { | ||
| this.nonce = nonce; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally set the user-facing name of the application the user is authenticating to. | ||
| * Duo shows this name in Duo Mobile and records it in the authentication log. | ||
| * | ||
| * @param destAppName The name of the destination application | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setDestAppName(String destAppName) { | ||
| this.destAppName = destAppName; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally set a long-lived unique identifier for the destination application. | ||
| * This value is not shown to users. | ||
| * | ||
| * @param destAppId The identifier of the destination application | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setDestAppId(String destAppId) { | ||
| this.destAppId = destAppId; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally set the username shown in the Duo Mobile "user" field for Duo Push. | ||
| * Duo shows the authenticating username when this is not set. This does not change which | ||
| * user Duo authenticates. | ||
| * | ||
| * @param displayUsername The username to display to the user | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setDisplayUsername(String displayUsername) { | ||
| this.displayUsername = displayUsername; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally limit how long ago the user's last interactive Duo authentication may have been. | ||
| * Duo forces the user to authenticate interactively again when a remembered session is older | ||
| * than this, and a value of {@code 0} always forces it. | ||
| * | ||
| * @param maxAge The number of seconds since the user last authenticated interactively | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setMaxAge(Integer maxAge) { | ||
| this.maxAge = maxAge; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Optionally set the OIDC {@code prompt} value. {@link Prompt#LOGIN} forces the user to | ||
| * authenticate interactively even when a remembered session exists, which is equivalent to | ||
| * {@link #setMaxAge(Integer)} with {@code 0}. It is the only value Duo currently accepts. | ||
| * | ||
| * @param prompt The prompt value to send | ||
| * | ||
| * @return the Builder | ||
| */ | ||
| public Builder setPrompt(Prompt prompt) { | ||
| this.prompt = prompt; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Build the options object. | ||
| * | ||
| * @return {@link AuthUrlOptions} | ||
| */ | ||
| public AuthUrlOptions build() { | ||
| return new AuthUrlOptions(this); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.