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

Access groups from payload #520

Merged
merged 3 commits into from
May 25, 2023
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ USER node
RUN npm install glob rimraf
RUN npm install

FROM node:16-alpine AS builder
FROM node:16-alpine AS builder

# Prepare app directory
WORKDIR /usr/src/app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AccessGroupFromPayloadService extends AccessGroupService {
}

Logger.log(
"ESS access groups getESSAccessGroupService : " + accessGroups.join(","),
"Access groups AccessGroupFromPayloadService : " + accessGroups.join(","),
);
return accessGroups;
}
Expand Down
3 changes: 3 additions & 0 deletions src/auth/strategies/oidc.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,15 @@ export class OidcStrategy extends PassportStrategy(Strategy, "oidc") {

async validate(tokenset: TokenSet): Promise<Omit<User, "password">> {
const userinfo: UserinfoResponse = await this.client.userinfo(tokenset);
const oidcConfig = this.configService.get<OidcConfig>("oidc");

const userProfile = this.parseUserInfo(userinfo);
const userPayload: UserPayload = {
userId: userProfile.id,
username: userProfile.username,
email: userProfile.email,
accessGroupProperty: oidcConfig?.accessGroupProperty,
payload: userinfo,
};
userProfile.accessGroups = await this.accessGroupService.getAccessGroups(
userPayload,
Expand Down
1 change: 1 addition & 0 deletions src/config/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const configuration = () => {
scope: process.env.OIDC_SCOPE, // Example: "openid profile email"
successURL: process.env.OIDC_SUCCESS_URL, // Example: http://localhost:3000/explorer
accessGroups: process.env.OIDC_ACCESS_GROUPS, // Example: None
accessGroupProperty: process.env.OIDC_ACCESS_GROUPS_PROPERTY, // Example: groups
autoLogout: process.env.OIDC_AUTO_LOGOUT || false,
returnURL: process.env.OIDC_RETURN_URL,
},
Expand Down