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

fix(oauth2): add roles to user info mapping #1880

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -80,6 +80,11 @@ public class EditOAuth2Command extends AbstractEditAuthnMethodCommand<OAuth2> {
description = "The username field returned from your OAuth provider.")
private String userInfoMappingUsername;

@Parameter(
names = "--user-info-mapping-roles",
description = "The roles field returned from your OAuth provider.")
private String userInfoMappingRoles;

@Parameter(
names = "--provider",
description =
Expand Down Expand Up @@ -144,6 +149,9 @@ protected AuthnMethod editAuthnMethod(OAuth2 authnMethod) {
userInfoMapping.setUsername(
isSet(userInfoMappingUsername) ? userInfoMappingUsername : userInfoMapping.getUsername());

userInfoMapping.setRoles(
isSet(userInfoMappingRoles) ? userInfoMappingRoles : userInfoMapping.getRoles());

authnMethod.setProvider(provider != null ? provider : authnMethod.getProvider());

if (!userInfoRequirements.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public void setProvider(Provider provider) {
newUserInfoMapping.setFirstName(userInfoMapping.getFirstName());
newUserInfoMapping.setLastName(userInfoMapping.getLastName());
newUserInfoMapping.setUsername(userInfoMapping.getUsername());
newUserInfoMapping.setRoles(userInfoMapping.getRoles());
break;
default:
throw new RuntimeException("Unknown provider type " + provider);
Expand Down Expand Up @@ -161,6 +162,7 @@ public static class UserInfoMapping {
private String firstName;
private String lastName;
private String username;
private String roles;
}

@Data
Expand Down