Skip to content

Commit 4e87057

Browse files
WIP
1 parent 6cd2f11 commit 4e87057

7 files changed

Lines changed: 164 additions & 224 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ accounts
77
profile
88
inbox
99
.acl
10-
config.json
10+
config.json

lib/create-app.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ var proxy = require('./handlers/proxy')
1010
var IdentityProvider = require('./identity-provider')
1111
var vhost = require('vhost')
1212
var path = require('path')
13-
var AnvilConnect = require('./handlers/auth-oidc')
14-
var bodyParser = require('body-parser')
13+
var OidcProvider = require('./oidc-provider')
1514

1615
var corsSettings = cors({
1716
methods: [
@@ -107,7 +106,17 @@ function createApp (argv) {
107106
ldp.oidc = true
108107
if (ldp.oidc) {
109108
var oidc = OidcProvider()
110-
app.use('/', oidc.authenticate())
109+
var localProviderConfig = {
110+
issuer: 'https://anvil.local',
111+
client_id: 'cfe8d9a7-e1f6-4b88-9d55-0be004a62870',
112+
client_secret: '62b0bc1698ff97bdc7c7',
113+
redirect_uri: 'https://ldnode.local:8443/api/oidc/rp'
114+
}
115+
// TODO: ensureTrustedClient is async, possible race condition on server
116+
// startup
117+
oidc.ensureTrustedClient(localProviderConfig)
118+
app.locals.oidc = oidc
119+
app.use('/', oidc.authenticate, oidc.authSessionInit)
111120
app.use('/api/oidc', oidc.middleware(corsSettings))
112121
}
113122

lib/handlers/auth-oidc.js

Lines changed: 0 additions & 190 deletions
This file was deleted.

lib/handlers/error-pages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ If you are not redirected automatically, follow the <a href='${url}'>link to log
6262

6363
function redirectToLogin (err, req, res, next) {
6464
res.header('Content-Type', 'text/html')
65-
var loginUrl = req.app.locals.oidcClient.urlForLogin(req)
65+
var loginUrl = req.app.locals.oidc.urlForSignin(req)
6666
debug('Redirecting to login: ' + loginUrl)
6767
var currentUrl = util.fullUrlForReq(req)
6868
req.session.returnToUrl = currentUrl

lib/oidc-client-store.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict'
2+
3+
module.exports.default = OIDClientStore
4+
5+
class OIDClientStore {
6+
constructor() {
7+
this.clients = {}
8+
}
9+
put(client) {
10+
return new Promise((resolve) => {
11+
this.clients[client.issuer] = client
12+
resolve()
13+
})
14+
}
15+
get(issuer) {
16+
return new Promise((resolve, reject) => {
17+
if (!issuer in this.clients) {
18+
resolve(null)
19+
} else {
20+
resolve(this.clients[issuer])
21+
}
22+
})
23+
}
24+
}

0 commit comments

Comments
 (0)