Skip to content

Commit a591ed0

Browse files
Send scope when requesting token
and using client credentials with spring auth server
1 parent 963b1a0 commit a591ed0

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

selenium/test/authnz-msg-protocols/amqp10.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ describe('Having AMQP 1.0 protocol enabled and the following auth_backends: ' +
5151
let oauthProviderUrl = process.env.OAUTH_PROVIDER_URL
5252
let oauthClientId = process.env.OAUTH_CLIENT_ID
5353
let oauthClientSecret = process.env.OAUTH_CLIENT_SECRET
54-
let tokenFormat = process.env.OAUTH_TOKEN_FORMAT || 'jwt'
54+
let scopes = process.env.OAUTH_SCOPES
5555
log("oauthProviderUrl : " + oauthProviderUrl)
5656
log("oauthClientId : " + oauthClientId)
5757
log("oauthClientSecret : " + oauthClientSecret)
58+
log("oauthScope : " + scopes)
5859
let openIdConfig = openIdConfiguration(oauthProviderUrl)
5960
log("Obtained token_endpoint : " + openIdConfig.token_endpoint)
60-
password = tokenFor(oauthClientId, oauthClientSecret, openIdConfig.token_endpoint)
61+
password = tokenFor(oauthClientId, oauthClientSecret, openIdConfig.token_endpoint, scopes)
6162
log("Obtained access token : " + password)
6263
amqpSettings.password = password
6364
setAmqpOptions(amqpSettings)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export RABBITMQ_AMQP_USERNAME=oauth
22
export OAUTH_CLIENT_ID=producer
33
export OAUTH_CLIENT_SECRET=producer
4+
export OAUTH_SCOPES="rabbitmq.configure:*/* rabbitmq.read:*/* rabbitmq.write:*/*"

selenium/test/authnz-msg-protocols/mqtt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ describe('Having MQTT protocol enbled and the following auth_backends: ' + backe
4444
let oauthProviderUrl = process.env.OAUTH_PROVIDER_URL
4545
let oauthClientId = process.env.OAUTH_CLIENT_ID
4646
let oauthClientSecret = process.env.OAUTH_CLIENT_SECRET
47+
let scope = process.env.OAUTH_SCOPES
4748
let openIdConfig = openIdConfiguration(oauthProviderUrl)
4849
log("Obtained token_endpoint : " + openIdConfig.token_endpoint)
49-
password = tokenFor(oauthClientId, oauthClientSecret, openIdConfig.token_endpoint)
50+
password = tokenFor(oauthClientId, oauthClientSecret, openIdConfig.token_endpoint, scope)
5051
log("Obtained access token : " + password)
5152
}
5253
mqttOptions = {

selenium/test/authnz-msg-protocols/spring/application.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ spring:
4747
- client_credentials
4848
client-authentication-methods:
4949
- client_secret_basic
50-
scope:
50+
scopes:
5151
- openid
5252
- profile
5353
- rabbitmq.tag:management
@@ -66,7 +66,7 @@ spring:
6666
- client_credentials
6767
client-authentication-methods:
6868
- client_secret_basic
69-
scope:
69+
scopes:
7070
- openid
7171
- profile
7272
- rabbitmq.tag:management
@@ -82,7 +82,7 @@ spring:
8282
- client_credentials
8383
client-authentication-methods:
8484
- client_secret_basic
85-
scope:
85+
scopes:
8686
- openid
8787
- profile
8888
- rabbitmq.tag:management

selenium/test/utils.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,16 @@ module.exports = {
236236
}
237237
},
238238

239-
tokenFor: (client_id, client_secret, url = uaaUrl, token_format = "jwt") => {
239+
tokenFor: (client_id, client_secret, url = uaaUrl, scope) => {
240240
const req = new XMLHttpRequest()
241-
const params = 'client_id=' + client_id +
241+
let params = 'client_id=' + client_id +
242242
'&client_secret=' + client_secret +
243243
'&grant_type=client_credentials' +
244-
'&token_format=' + token_format +
244+
// '&token_format=' + token_format +
245245
'&response_type=token'
246+
if (scope != undefined && scope != "") {
247+
params = params + '&scope=' + scope
248+
}
246249

247250
req.open('POST', url, false)
248251
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

0 commit comments

Comments
 (0)