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

Support set roles using OAuth claims #322

Open
oneonestar opened this issue Apr 16, 2024 · 0 comments
Open

Support set roles using OAuth claims #322

oneonestar opened this issue Apr 16, 2024 · 0 comments

Comments

@oneonestar
Copy link
Member

Currently, we authenticate an user and get the userId from OAuth provider.
The mapping between userId and role is done by setting the presetUsers.
If userId exists in presetUsers, we'll use the privileges set for the user and match it in authorization.

It's inconvenient to set every account in presetUsers in order to perform a userId to role mapping.
We can improve this by getting the info from OAuth claims.

A similar feature already exist in LDAP (lbLdapClient.getMemberOf(username)).
This feature also exists in Trino (trinodb/trino#15669), although it's discouraged due to the conflict with impersonation. We don't have impersonation in gateway, so this won't be a concert.

Ref:

authentication:
  defaultType: "oauth"
  oauth:
    issuer: ....

authorization:
  admin: (.*)ADMIN(.*)
  user: (.*)USER(.*)
  api: (.*)API(.*)

presetUsers:
  alice:
    privileges: ADMIN_USER_API

public Optional<String> getPrivileges(String username)
{
//check the preset users
String privs = "";
UserConfiguration user = presetUsers.get(username);
if (user != null) {
privs = user.privileges();
}
else if (lbLdapClient != null) {
privs = lbLdapClient.getMemberOf(username);
}
return Optional.ofNullable(privs);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant