Skip to content

Commit 8b51643

Browse files
authored
Merge pull request #50 from nodeSolidServer/fix/issue#48
Scope normalization logic that converts array scope parameters to space-separated strings before validation
2 parents d6c62f6 + 41068a8 commit 8b51643

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/AuthenticationRequest.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class AuthenticationRequest {
5050
client = { client_id: registration.client_id}
5151
params = Object.assign(defaults.authenticate, client, options)
5252

53+
// normalize scope parameter - convert array to space-separated string if needed
54+
if (Array.isArray(params.scope)) {
55+
params.scope = params.scope.join(' ')
56+
}
57+
5358
// validate presence of required configuration and parameters
5459
assert(issuer,
5560
'Missing issuer in provider OpenID Configuration')

test/AuthenticationRequestSpec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,13 @@ describe('AuthenticationRequest', () => {
182182
})
183183
})
184184

185+
it('should handle array scope parameters', () => {
186+
options = { scope: ['openid', 'webid', 'profile'] }
187+
return AuthenticationRequest.create(rp, options, session).then(url => {
188+
url.should.include('scope=openid%20webid%20profile')
189+
})
190+
})
191+
185192
it('should set `client_id` parameter', () => {
186193
return AuthenticationRequest.create(rp, options, session).then(url => {
187194
url.should.include('client_id=uuid')

0 commit comments

Comments
 (0)