WIP: Got the SAML login working

TODO: Cleanup, remove hardcoded url.
This commit is contained in:
J Shamsul Bahri (jibone))
2020-09-04 13:56:54 +08:00
parent bd7e8cc78e
commit 1ae5a74c3a
25 changed files with 698 additions and 84 deletions
@@ -62,6 +62,7 @@ export const createAuthProviderRouter = (
for (const env of envs) {
const envConfig = providerConfig.getConfig(env);
console.log(envConfig);
const provider = factory(globalConfig, env, envConfig, logger, issuer);
if (provider) {
envProviders[env] = provider;
@@ -55,8 +55,21 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers {
// for non-oauth auth flows.
// TODO: This flow doesn't issue an identity token that can be used to validate
// the identity of the user in other backends, which we need in some form.
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===>');
console.log('===> SamlAuthProvider constructor');
console.log(profile);
done(undefined, {
userId: profile.ID!,
userId: profile.nameID!,
profile: {
email: profile.email!,
displayName: profile.displayName as string,
@@ -76,9 +89,9 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers {
): Promise<void> {
try {
const {
response: { userId, profile },
response: { userId, profile },
} = await executeFrameHandlerStrategy<SamlInfo>(req, this.strategy);
const id = userId;
const idToken = await this.tokenIssuer.issueToken({
claims: { sub: id },
@@ -107,8 +120,14 @@ export class SamlAuthProvider implements AuthProviderRouteHandlers {
res.send('noop');
}
identifyEnv(): string | undefined {
return undefined;
identifyEnv(req: express.Request): string | undefined {
const reqEnv = req.query.env?.toString();
if (reqEnv) {
return reqEnv;
}
// FIXME : do we want to always to return 'development' ?
return 'development';
}
}