@dt-esa/authorizer
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -0,0 +0,0 @@ declare enum Scope { |
@@ -0,0 +0,0 @@ "use strict"; |
export declare const Client: (router: any, options: any) => void; |
@@ -30,3 +30,3 @@ "use strict"; | ||
: [] || []; // Always default as an empty array. | ||
req._username = data.name; | ||
req._username = data.name.toLowerCase(); | ||
req._authorizedScopes = data.permissions.concat(locallyAppliedPermissions); | ||
@@ -33,0 +33,0 @@ return next(); |
@@ -1,2 +0,1 @@ | ||
import { SessionStoreClient } from '@dt-esa/level-cluster'; | ||
export declare const Dynatrace: (router: any, usercache: SessionStoreClient, options: any) => void; | ||
export declare const Dynatrace: (router: any, usercache: any, options: any) => void; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -1,3 +0,1 @@ | ||
import { SessionStoreClient } from "@dt-esa/level-cluster"; | ||
import { ConfigParams } from "express-openid-connect"; | ||
export declare const OpenId: (router: any, cache: SessionStoreClient, options: ConfigParams) => void; | ||
export declare const OpenId: (router: any, cache: any, options: any) => void; |
@@ -38,3 +38,3 @@ "use strict"; | ||
if (req.oidc && req.oidc.user) | ||
req._username = req.oidc.user.upn; | ||
req._username = req.oidc.user.upn.toLowerCase(); | ||
next(); | ||
@@ -41,0 +41,0 @@ }); |
@@ -1,2 +0,1 @@ | ||
import { SessionStoreClient } from '@dt-esa/level-cluster'; | ||
export declare const Saml: (router: any, cache: SessionStoreClient, options: any, passport: Passport) => void; | ||
export declare const Saml: (router: any, cache: any, options: any, passport: any) => void; |
@@ -35,3 +35,3 @@ "use strict"; | ||
const email = (_a = req.user) === null || _a === void 0 ? void 0 : _a.nameID; | ||
req._username = email; | ||
req._username = email.toLowerCase(); | ||
} | ||
@@ -38,0 +38,0 @@ next(); |
@@ -1,5 +0,5 @@ | ||
import { AxiosInstance } from 'axios'; | ||
import { SharedSessionStore } from "@dt-esa/level-cluster"; | ||
import { AxiosInstance } from "axios"; | ||
import { ConfigParams } from "express-openid-connect"; | ||
import { ScopeMap } from "./dynatrace-scopes"; | ||
import { SessionStoreOptions, SharedSessionStore } from "@dt-esa/level-cluster"; | ||
import { ConfigParams } from "express-openid-connect"; | ||
export interface PermissionMap { | ||
@@ -9,3 +9,2 @@ [key: string]: Array<string>; | ||
export declare type AuthenticationOptions = { | ||
sessionSyncPort?: number; | ||
authorizations?: PermissionMap; | ||
@@ -67,3 +66,3 @@ scopeMappings?: ScopeMap; | ||
*/ | ||
export declare const authentication: (options: AuthenticationOptions) => import("express-serve-static-core").Router; | ||
export declare const authentication: (options: any) => any; | ||
/** | ||
@@ -77,3 +76,3 @@ * Connect-style middleware that asserts all permissions are satisfied by the | ||
*/ | ||
export declare const authorize: (permissions?: Array<string>) => (req: any, res: any, next: any) => any; | ||
export declare const authorize: (permissions?: any[]) => (req: any, res: any, next: any) => any; | ||
/** | ||
@@ -89,2 +88,2 @@ * Method to initialize the shared user cache. | ||
*/ | ||
export declare const SharedUserCache: (port: number, options: SessionStoreOptions) => SharedSessionStore<unknown>; | ||
export declare const SharedUserCache: (port: any, options: any) => SharedSessionStore<unknown>; |
@@ -7,9 +7,9 @@ "use strict"; | ||
exports.SharedUserCache = exports.authorize = exports.authentication = void 0; | ||
const express_1 = __importDefault(require("express")); | ||
const passport_1 = __importDefault(require("passport")); | ||
const level_cluster_1 = require("@dt-esa/level-cluster"); | ||
const client_1 = require("./flows/client"); | ||
const dynatrace_1 = require("./flows/dynatrace"); | ||
const level_cluster_1 = require("@dt-esa/level-cluster"); | ||
const openid_1 = require("./flows/openid"); | ||
const saml_1 = require("./flows/saml"); | ||
const openid_1 = require("./flows/openid"); | ||
const client_1 = require("./flows/client"); | ||
const passport_1 = __importDefault(require("passport")); | ||
const express_1 = __importDefault(require("express")); | ||
/** | ||
@@ -62,2 +62,7 @@ * Connect-style middleware that sets up SSO authorization via passport. | ||
const cache = new level_cluster_1.SessionStoreClient(port, "@dynatrace-esa/authorizer"); | ||
options.authorizations = options.authorizations || []; | ||
// Reference ALL users with lowercase Ids. | ||
Object.keys(options.authorizations).forEach(userId => { | ||
options.authorizations[userId.toLowerCase()] = options.authorizations[userId]; | ||
}); | ||
// Initialize Passport. | ||
@@ -86,2 +91,3 @@ router.use(passport_1.default.initialize()); | ||
router.use((req, res, next) => { | ||
var _a; | ||
// Decorate all SSO login flows. | ||
@@ -91,3 +97,3 @@ // Dynatrace flow will add scopes automatically. | ||
req._authorizedScopes = | ||
req._authorizedScopes.concat(options.authorizations ? options.authorizations[req._username] || [] : []); | ||
req._authorizedScopes.concat(options.authorizations[(_a = req._username) === null || _a === void 0 ? void 0 : _a.toLowerCase()] || []); | ||
next(); | ||
@@ -94,0 +100,0 @@ }); |
{ | ||
"name": "@dt-esa/authorizer", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
662
33027