Skip to content

Commit 3fb8047

Browse files
Move Provider initialization logic
1 parent 7a0376f commit 3fb8047

3 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎lib/capability-discovery.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const serviceConfigDefaults = {
1414
// Create new user (see IdentityProvider.post() in identity-provider.js)
1515
'new': '/api/accounts/new',
1616
'recover': '/api/accounts/recover',
17-
'signin': '/api/accounts/signin',
18-
'signout': '/api/accounts/signout',
17+
'signin': '/login',
18+
'signout': '/logout',
1919
'validateToken': '/api/accounts/validateToken'
2020
}
2121
}

‎lib/create-app.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,19 @@ function initAuthentication (argv, app) {
190190
// and OIDC-specific ones
191191
app.use('/', API.oidc.middleware(oidc))
192192

193+
oidc.initialize()
194+
.then(() => {
195+
oidc.saveProviderConfig()
196+
return oidc.clients.clientForIssuer(argv.serverUri)
197+
})
198+
.then(localClient => {
199+
console.log('Local RP client initialized')
200+
oidc.localRp = localClient
201+
})
202+
.catch(error => {
203+
console.error(error)
204+
})
205+
193206
// Enforce authentication with WebID-OIDC on all LDP routes
194207
app.use('/', oidc.rs.authenticate())
195208
break

‎lib/models/oidc-manager.js‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,8 @@ function fromServerConfig (argv) {
4040
saltRounds: argv.saltRounds,
4141
host: { authenticate, obtainConsent, logout }
4242
}
43-
let oidc = OidcManager.from(options)
44-
oidc.initialize()
45-
.then(() => {
46-
oidc.saveProviderConfig()
47-
return oidc.clients.clientForIssuer(providerUri)
48-
})
49-
.then(localClient => {
50-
console.log('Local RP client initialized')
51-
oidc.localRp = localClient
52-
})
53-
54-
return oidc
43+
44+
return OidcManager.from(options)
5545
}
5646

5747
// This gets called from OIDC Provider's /authorize endpoint

0 commit comments

Comments
 (0)