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
53 lines (46 loc) · 1.54 KB
/
Copy pathoidc-manager.js
File metadata and controls
53 lines (46 loc) · 1.54 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
49
50
51
52
53
'use strict'
/* eslint-disable node/no-deprecated-api */
const url = require('url')
const path = require('path')
const debug = require('../debug').authentication
const OidcManager = require('@solid/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
*
* @param [argv.delayBeforeRegisteringInitialClient] {number} Number of
* milliseconds to delay before initializing a local RP client.
*
* @return {OidcManager} Initialized instance, includes a UserStore,
* OIDC Clients store, a Resource Authenticator, and an OIDC Provider.
*/
function fromServerConfig (argv) {
const providerUri = argv.host.serverUri
const authCallbackUri = url.resolve(providerUri, '/api/oidc/rp')
const postLogoutUri = url.resolve(providerUri, '/goodbye')
const dbPath = path.join(argv.dbPath, 'oidc')
const options = {
debug,
providerUri,
dbPath,
authCallbackUri,
postLogoutUri,
saltRounds: argv.saltRounds,
delayBeforeRegisteringInitialClient: argv.delayBeforeRegisteringInitialClient,
host: { debug }
}
return OidcManager.from(options)
}
module.exports = {
fromServerConfig
}