Как сделать так, чтобы UAA возвращало JWT с дополнительной областью действия, например, scim.read - PullRequest
0 голосов
/ 18 июня 2019

Я планирую использовать UAA в качестве менеджера по работе с клиентами.Я нахожусь в точке, где мне нужно получить доступ к деталям других пользователей, но я получаю 401 Несанкционированную ошибку, когда я достигаю конечную точку GET /Users.https://github.com/cloudfoundry/uaa/blob/develop/docs/UAA-APIs.rst#query-for-information-get-users

Поскольку для включения требуется область действия scim.read, я добавил его к пользователю

$uaac user add user1 -p user1 --emails user1@test.com
$uaac member add scim.read user1

Но когда я звоню, я получаю 401

Этоmy uaa.yml

oauth:
  user:
    authorities:
      - openid
      - scim.me
      - password.write
      - scim.userids
      - uaa.user
      - approvals.me
      - oauth.approvals
  clients:
    sample_resource:
      name: Mixed Messages
      secret: samplesecret
      authorized-grant-types: authorization_code
      scope: openid,profile,email,messages,contacts,phone,roles,user_attributes,scim.read
      authorities: uaa.resource
      redirect-uri: http://localhost:8090/login/oauth2/code/localuaa,http://localhost:8080
    admin:
      secret: adminsecret
      authorized-grant-types: client_credentials
      authorities: contacts
    expired:
      secret: secret
      access-token-validity: 1
      authorized-grant-types: client_credentials
      scope: contacts

и application.yaml моего приложения

# Local instance of UAA
spring.security.oauth2.client.provider.localuaa.issuer-uri: http://localhost:8080/uaa/oauth/token
resource.uaa-base-uri: http://localhost:8080/uaa
spring.security.oauth2.client.registration.localuaa.client-id: sample_resource
spring.security.oauth2.client.registration.localuaa.client-secret: samplesecret

Когда я просматриваю маркер доступа (jwt), возвращенный UAA, я надеюсь увидеть scim.read в области, но это не так.

В соответствии с этим, https://docs.cloudfoundry.org/uaa/uaa-concepts.html#scopes, область должна содержать пересечение групп пользователей и области клиента.

{
  "sub": "476849cb-d975-4fb7-979f-acd8fc05f6db",
  "aud": [
    "sample_resource"
  ],
  "iss": "http://localhost:8080/uaa/oauth/token",
  "exp": 1560849541,
  "iat": 1560806341,
  "amr": [
    "pwd"
  ],
  "azp": "sample_resource",
  "scope": [
    "openid"
  ],
  "email": "user1@test.com",
  "zid": "uaa",
  "origin": "uaa",
  "jti": "b8111a33a8c34f09a14942c70e797a95",
  "email_verified": true,
  "client_id": "sample_resource",
  "cid": "sample_resource",
  "grant_type": "authorization_code",
  "user_name": "user1",
  "rev_sig": "efb7c4c8",
  "user_id": "476849cb-d975-4fb7-979f-acd8fc05f6db",
  "auth_time": 1560806338
}

ОБНОВЛЕНИЕ:Я понял, что клиент делает запрос

http://localhost:8080/uaa/oauth/authorize?response_type=code&client_id=sample_resource&scope=openid%20profile%20email%20phone%20roles%20user_attributes&state=2BeBQtOJieu-A_3FfurWqjma_AJ3jsQcrpTgxtrDJqo%3D&redirect_uri=http://localhost:8090/login/oauth2/code/localuaa

, используя области, как определено по умолчанию scopes_supported в http://localhost:8080/uaa/.well-known/openid-configuration И это, кажется, переопределяет конфигурацию области в зарегистрированном клиенте.

...