Skip to content

Commit c8986cf

Browse files
authored
Merge pull request #1012 from rubensworks/fix/no-defined-origin
Add server origin by default to the list of trusted origins
2 parents 4d52960 + 3f3fd8f commit c8986cf

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/handlers/allow.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function allow (mode) {
5050
},
5151
suffix: ldp.suffixAcl,
5252
strictOrigin: ldp.strictOrigin,
53-
trustedOrigins: ldp.trustedOrigins
53+
trustedOrigins: [ldp.resourceMapper.resolveUrl(req.hostname)].concat(ldp.trustedOrigins)
5454
})
5555

5656
// Ensure the user has the required permission

test/integration/authentication-oidc-test.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('Authentication API (OIDC)', () => {
212212
})
213213
})
214214

215-
// Our origin isn't trusted by default
215+
// Our origin is trusted by default
216216
describe('with that cookie and our origin', () => {
217217
let response
218218
before(done => {
@@ -225,6 +225,24 @@ describe('Authentication API (OIDC)', () => {
225225
})
226226
})
227227

228+
it('should return a 200', () => {
229+
expect(response).to.have.property('status', 200)
230+
})
231+
})
232+
233+
// Another origin isn't trusted by default
234+
describe('with that cookie and our origin', () => {
235+
let response
236+
before(done => {
237+
alice.get('/')
238+
.set('Cookie', cookie)
239+
.set('Origin', 'https://some.other.domain.com')
240+
.end((err, res) => {
241+
response = res
242+
done(err)
243+
})
244+
})
245+
228246
it('should return a 403', () => {
229247
expect(response).to.have.property('status', 403)
230248
})

0 commit comments

Comments
 (0)