mirror of https://github.com/requarks/wiki
parent
7008ec8dcc
commit
df91335f11
@ -1,56 +0,0 @@
|
|||||||
const _ = require('lodash')
|
|
||||||
|
|
||||||
// ------------------------------------
|
|
||||||
// Azure AD Account
|
|
||||||
// ------------------------------------
|
|
||||||
|
|
||||||
const OIDCStrategy = require('passport-azure-ad').OIDCStrategy
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
init (passport, conf) {
|
|
||||||
// Workaround for Chrome's SameSite cookies
|
|
||||||
// cookieSameSite needs useCookieInsteadOfSession to work correctly.
|
|
||||||
// cookieEncryptionKeys is extracted from conf.cookieEncryptionKeyString.
|
|
||||||
// It's a concatnation of 44-character length strings each of which represents a single pair of key/iv.
|
|
||||||
// Valid cookieEncryptionKeys enables both cookieSameSite and useCookieInsteadOfSession.
|
|
||||||
const keyArray = [];
|
|
||||||
if (conf.cookieEncryptionKeyString) {
|
|
||||||
let keyString = conf.cookieEncryptionKeyString;
|
|
||||||
while (keyString.length >= 44) {
|
|
||||||
keyArray.push({ key: keyString.substring(0, 32), iv: keyString.substring(32, 44) });
|
|
||||||
keyString = keyString.substring(44);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
passport.use(conf.key,
|
|
||||||
new OIDCStrategy({
|
|
||||||
identityMetadata: conf.entryPoint,
|
|
||||||
clientID: conf.clientId,
|
|
||||||
redirectUrl: conf.callbackURL,
|
|
||||||
responseType: 'id_token',
|
|
||||||
responseMode: 'form_post',
|
|
||||||
scope: ['profile', 'email', 'openid'],
|
|
||||||
allowHttpForRedirectUrl: WIKI.IS_DEBUG,
|
|
||||||
passReqToCallback: true,
|
|
||||||
cookieSameSite: keyArray.length > 0,
|
|
||||||
useCookieInsteadOfSession: keyArray.length > 0,
|
|
||||||
cookieEncryptionKeys: keyArray
|
|
||||||
}, async (req, iss, sub, profile, cb) => {
|
|
||||||
const usrEmail = _.get(profile, '_json.email', null) || _.get(profile, '_json.preferred_username')
|
|
||||||
try {
|
|
||||||
const user = await WIKI.db.users.processProfile({
|
|
||||||
providerKey: req.params.strategy,
|
|
||||||
profile: {
|
|
||||||
id: profile.oid,
|
|
||||||
displayName: profile.displayName,
|
|
||||||
email: usrEmail,
|
|
||||||
picture: ''
|
|
||||||
}
|
|
||||||
})
|
|
||||||
cb(null, user)
|
|
||||||
} catch (err) {
|
|
||||||
cb(err, null)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
key: azure
|
|
||||||
title: Azure Active Directory
|
|
||||||
description: Azure Active Directory (Azure AD) is Microsoft's multi-tenant, cloud-based directory, and identity management service that combines core directory services, application access management, and identity protection into a single solution.
|
|
||||||
author: requarks.io
|
|
||||||
logo: https://static.requarks.io/logo/azure.svg
|
|
||||||
icon: /_assets/icons/ultraviolet-azure.svg
|
|
||||||
color: blue darken-3
|
|
||||||
website: https://azure.microsoft.com/services/active-directory/
|
|
||||||
isAvailable: true
|
|
||||||
useForm: false
|
|
||||||
scopes:
|
|
||||||
- profile
|
|
||||||
- email
|
|
||||||
- openid
|
|
||||||
props:
|
|
||||||
entryPoint:
|
|
||||||
type: String
|
|
||||||
title: Identity Metadata Endpoint
|
|
||||||
hint: The metadata endpoint provided by the Microsoft Identity Portal that provides the keys and other important information at runtime.
|
|
||||||
order: 1
|
|
||||||
clientId:
|
|
||||||
type: String
|
|
||||||
title: Client ID
|
|
||||||
hint: The client ID of your application in AAD (Azure Active Directory)
|
|
||||||
order: 2
|
|
||||||
cookieEncryptionKeyString:
|
|
||||||
type: String
|
|
||||||
title: Cookie Encryption Key String
|
|
||||||
hint: Random string with 44-character length. Setting this enables workaround for Chrome's SameSite cookies.
|
|
||||||
order: 3
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue