Skip to content

Commit

Permalink
[MLZ] Add accessgroup from userinfo
Browse files Browse the repository at this point in the history
Change-Id: I742fef97fa9235be7e71d2b1f27529e666215696
  • Loading branch information
bpedersen2 committed Sep 8, 2023
1 parent d6cef6b commit 547531d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CI/MLZ/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV NODE_ENV "development"
ENV PORT 3000
EXPOSE 3000
# create local user to avoid running as root
RUN addgroup mygroup
RUN addgroup mygroup
RUN useradd -ms /bin/bash myuser
RUN mkdir -p /usr/src/app && chown -R myuser /usr/src/app
# Prepare app directory
Expand All @@ -30,6 +30,7 @@ COPY CI/MLZ/component-config.json /usr/src/app/server/
COPY CI/MLZ/envfiles/settings.json /usr/src/app/test/config/
COPY CI/MLZ/start.sh /usr/src/app/start.sh
COPY CI/MLZ/frontend.config.json /usr/src/app/src/config/
RUN mv /usr/src/app/CI/MLZ/MLZ-access-group-service-factory.ts /usr/src/auth/access-group-provider/access-group-service-factory.ts && \

# Start the app
RUN cat /usr/src/app/server/datasources.json
Expand Down
33 changes: 33 additions & 0 deletions CI/MLZ/MLZ-access-group-service-factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { HttpService } from "@nestjs/axios";
import { ConfigService } from "@nestjs/config";
//import { AccessGroupFromOidcApiService } from "./access-group-from-oidc.service";
import { AccessGroupFromMultipleProvidersService } from "./access-group-from-multiple-providers.service";
import { AccessGroupFromPayloadService } from "./access-group-from-payload.service";
import { AccessGroupFromStaticValuesService } from "./access-group-from-static-values.service";
import { AccessGroupService } from "./access-group.service";

export const accessGroupServiceFactory = {
provide: AccessGroupService,
useFactory: (configService: ConfigService) => {
return getMLZAccessGroupService(configService);
},
inject: [ConfigService],
};

function getMLZAccessGroupService(configService: ConfigService) {
const accessGroupsStaticValues = configService.get(
"accessGroupsStaticValues",
);
const fromPayload = new AccessGroupFromPayloadService(configService);
const fromStatic = new AccessGroupFromStaticValuesService(
accessGroupsStaticValues,
);

const fromMultiple = new AccessGroupFromMultipleProvidersService([
fromPayload,
fromStatic,
]);

return fromMultiple;
}

0 comments on commit 547531d

Please sign in to comment.