forked from nodeSolidServer/node-solid-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoidc-manager.js
More file actions
48 lines (41 loc) · 1.27 KB
/
oidc-manager.js
File metadata and controls
48 lines (41 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict'
const url = require('url')
const path = require('path')
const debug = require('../debug').authentication
const OidcManager = require('oidc-auth-manager')
/**
* Returns an instance of the OIDC Authentication Manager, initialized from
* argv / config.json server parameters.
*
* @param argv {Object} Config hashmap
*
* @param argv.host {SolidHost} Initialized SolidHost instance, including
* `serverUri`.
*
* @param [argv.dbPath='./db/oidc'] {string} Path to the auth-related storage
* directory (users, tokens, client registrations, etc, will be stored there).
*
* @param argv.saltRounds {number} Number of bcrypt password salt rounds
*
* @return {OidcManager} Initialized instance, includes a UserStore,
* OIDC Clients store, a Resource Authenticator, and an OIDC Provider.
*/
function fromServerConfig (argv) {
let providerUri = argv.host.serverUri
let authCallbackUri = url.resolve(providerUri, '/api/oidc/rp')
let postLogoutUri = url.resolve(providerUri, '/goodbye')
let dbPath = path.join(argv.dbPath, 'oidc')
let options = {
debug,
providerUri,
dbPath,
authCallbackUri,
postLogoutUri,
saltRounds: argv.saltRounds,
host: { debug }
}
return OidcManager.from(options)
}
module.exports = {
fromServerConfig
}