Skip to content

Commit a961a32

Browse files
WIP (moving oidcConfig to config.json)
1 parent 3f7504d commit a961a32

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

lib/create-app.js

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var corsSettings = cors({
2929
function createApp (argv = {}) {
3030
var ldp = new LDP(argv)
3131
var app = express()
32+
var oidcConfig = argv.oidc
3233

3334
// check if we have master ACL or not
3435
var masterAcl
@@ -84,40 +85,14 @@ function createApp (argv = {}) {
8485
// Session
8586
app.use(session(sessionSettings))
8687

87-
ldp.oidcConfig = {
88-
issuer: 'https://anvil.local',
89-
client_id: '54f94171-de00-41fa-bba2-7da4f1c01fde',
90-
client_secret: 'aa3c819b16460632c516',
91-
redirect_uri: 'https://ldnode.local:8443/api/oidc/rp'
92-
}
93-
if (ldp.oidcConfig) {
88+
if (oidcConfig) {
9489
var oidc = new OidcProvider()
9590
// TODO: ensureTrustedClient is async, possible race condition on server
9691
// startup
9792
debug.idp('Initializing local/trusted client...')
98-
oidc.ensureTrustedClient(ldp.oidcConfig)
93+
oidc.ensureTrustedClient(oidcConfig)
9994
app.locals.oidc = oidc
100-
// app.use('/', oidc.authenticate.bind(oidc))
101-
app.use('/',
102-
oidc.loadAuthClient.bind(oidc),
103-
104-
(req, res, next) => {
105-
debug.oidc('in authWithClient():')
106-
if (!req.oidcClient) {
107-
debug.oidc(' * No oidcClient found, next()')
108-
return next()
109-
}
110-
const client = req.oidcClient
111-
const verifyOptions = {
112-
allowNoToken: true,
113-
loadUserInfo: true
114-
}
115-
let verifier = client.verifier(verifyOptions)
116-
verifier(req, res, next)
117-
},
118-
119-
oidc.authSessionInit.bind(oidc)
120-
)
95+
app.use('/', oidc.authenticate().bind(oidc))
12196
app.use('/api/oidc', oidc.middleware(corsSettings))
12297
}
12398

lib/oidc-provider.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ module.exports = class Provider {
5959
var router = express.Router('/')
6060
var oidc = this
6161
router.use('/',
62-
(req, res, next) => {
63-
debug.oidc('in authenticate()..')
64-
},
6562
oidc.loadAuthClient.bind(oidc),
63+
6664
(req, res, next) => {
6765
debug.oidc('in authWithClient():')
6866
if (!req.oidcClient) {
@@ -77,6 +75,7 @@ module.exports = class Provider {
7775
let verifier = client.verifier(verifyOptions)
7876
verifier(req, res, next)
7977
},
78+
8079
oidc.authSessionInit.bind(oidc)
8180
)
8281
return router

0 commit comments

Comments
 (0)