Skip to content
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

feat: optionally add domain_hint #628

Merged
merged 2 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
public static final String CONVERTER_DISABLE_GRAPH_INTEGRATION = "disableGraphIntegration";
public static final String CONVERTER_SINGLE_LOGOUT = "singleLogout";
public static final String CONVERTER_PROMPT_ACCOUNT = "promptAccount";
public static final String CONVERTER_DOMAIN_HINT = "domainHint";

public static final String CONVERTER_ENVIRONMENT_NAME = "environmentName";

Expand All @@ -137,6 +138,7 @@
private boolean disableGraphIntegration;
private String azureEnvironmentName = "Azure";
private String credentialType = "Secret";
private String domainHint = "";

public AccessToken getAccessToken() {
TokenRequestContext tokenRequestContext = new TokenRequestContext();
Expand Down Expand Up @@ -192,6 +194,15 @@
this.promptAccount = promptAccount;
}

public String getDomainHint() {
return domainHint;
}

@DataBoundSetter
public void setDomainHint(String domainHint) {
this.domainHint = domainHint;
}

public boolean isSingleLogout() {
return singleLogout;
}
Expand Down Expand Up @@ -371,6 +382,9 @@
if (promptAccount) {
additionalParams.put("prompt", "select_account");
}
if (!StringUtils.isBlank(domainHint)) {
additionalParams.put("domain_hint", domainHint);

Check warning on line 386 in src/main/java/com/microsoft/jenkins/azuread/AzureSecurityRealm.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 385-386 are not covered by tests
}

return new HttpRedirect(service.getAuthorizationUrl(additionalParams));
}
Expand Down Expand Up @@ -702,6 +716,10 @@
writer.startNode(CONVERTER_SINGLE_LOGOUT);
writer.setValue(String.valueOf(realm.isSingleLogout()));
writer.endNode();

writer.startNode(CONVERTER_DOMAIN_HINT);
writer.setValue(String.valueOf(realm.getDomainHint()));
writer.endNode();
}

@Override
Expand Down Expand Up @@ -745,6 +763,9 @@
case CONVERTER_SINGLE_LOGOUT:
realm.setSingleLogout(Boolean.parseBoolean(value));
break;
case CONVERTER_DOMAIN_HINT:
realm.setDomainHint(value);
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,35 @@
<f:textbox />
</f:entry>

<f:entry title="${%Azure Environment}" field="azureEnvironmentName">
<f:select/>
</f:entry>
<f:advanced>
<f:entry title="${%Azure Environment}" field="azureEnvironmentName">
<f:select/>
</f:entry>
<f:entry title="Cache Duration" field="cacheDuration">
<f:number default="3600"/>
</f:entry>

<f:entry title="Cache Duration" field="cacheDuration">
<f:number default="3600" />
</f:entry>
<f:entry title="Callback URL from request" field="fromRequest">
<f:checkbox/>
</f:entry>

<f:entry title="Callback URL from request" field="fromRequest">
<f:checkbox />
</f:entry>
<f:entry title="${%Prompt for user account on each login}" field="promptAccount">
<f:checkbox/>
</f:entry>

<f:entry title="${%Prompt for user account on each login}" field="promptAccount">
<f:checkbox />
</f:entry>
<f:entry title="${%Domain Hint}" description="${%The realm of the user in a federated directory}"
field="domainHint">
<f:textbox/>
</f:entry>

<f:entry title="${%Enable Single Logout}" field="singleLogout">
<f:checkbox/>
</f:entry>

<f:entry title="${%Enable Single Logout}" field="singleLogout">
<f:checkbox />
</f:entry>

<f:entry title="${%Disable graph integration}" field="disableGraphIntegration">
<f:checkbox />
</f:entry>
<f:entry title="${%Disable graph integration}" field="disableGraphIntegration">
<f:checkbox/>
</f:entry>
</f:advanced>

<f:entry title="Test user principal name or object id">
<f:textbox name="testObject" />
Expand Down
Loading