rabbitmq / rabbitmq-oauth2-tutorial

Explore integration of RabbitMQ with Oauth 2.0 auth backend plugin
42 stars 23 forks source link

Keycloak example does not work #10

Closed dmitrynovik closed 1 year ago

dmitrynovik commented 1 year ago

Running the keycloak example out of the box, as per guide, on the recent main branch:

sudo make start-keycloak

export MODE=keycloak
sudo make start-rabbitmq

Trying to obtain the token for the management UI login...

As seen in below output from the bin/keycloak/curl script, the access token is granted, but it does not work: curl -u :$ACCESS_TOKEN $URL produces not_authorized:

make curl-keycloak url=http://localhost:15672/api/overview client_id=mgt_api_client secret=LWOuYqJ8gjKg3D2U8CJZDuID3KiRZVDa
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1190  100  1089  100   101   5854    543 --:--:-- --:--:-- --:--:--  6432
TOKEN : {"access_token":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJHbmwyWmxiUmgzckFyNld5bWM5ODhfNWNZN1Q1R3VlUGQ1ZHBKbFhESlVrIn0.eyJleHAiOjE2Njk5Mzk5MzgsImlhdCI6MTY2OTkzOTYzOCwianRpIjoiYWQ2NjdlM2UtNDAwMi00ZDlmLWIzMTQtNGExNzY1MzZjMmFjIiwiaXNzIjoiaHR0cDovL2xvY2FsaG9zdDo4MDgwL3JlYWxtcy90ZXN0IiwiYXVkIjoicmFiYml0bXEiLCJzdWIiOiIxNWYwMzM0Ny1lMmZjLTRmOGMtOTc0My1mNGRmZDU5ZjY3ZmUiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJtZ3RfYXBpX2NsaWVudCIsInNjb3BlIjoiZW1haWwgcmFiYml0bXEudGFnOm1hbmFnZW1lbnQiLCJjbGllbnRJZCI6Im1ndF9hcGlfY2xpZW50IiwiY2xpZW50SG9zdCI6IjE3Mi4xOC4wLjEiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImNsaWVudEFkZHJlc3MiOiIxNzIuMTguMC4xIn0.A_vIndPoH2Koh8du5A0HG8NnTC1s7VdLFIjEcPQhqnSLuk5HemUAj9T8xHIBdRCqqYFWQOdY-77s3poGgDtcZiXUppgCwvEDaduZzZ--MOwOVxh2H5r_zprUgwri8bxs7vtr2TzfcAFCkdT36x0GoxrnQzRMVvYTUv1lWRRszDnoNL8oOVMNYcGb7qONX7oYnjm9h7iX0NQfvBhnouozBR7chMfdbL7mFU_WLKEfqzRMOQdUCfA2wsdhmP8m2c2VTQaJy_5k1ySd18gwZeJPpbPavB3kfpepOovL_MNDeegfBf5B20wSWqLATzHuDMXRB_ZAadZ6iNnXxsM1ei27Yg","expires_in":300,"refresh_expires_in":0,"token_type":"Bearer","not-before-policy":0,"scope":"email rabbitmq.tag:management"}
{"error":"not_authorized","reason":"Login failed"}

ROOT CAUSE: the Makefile ignores the MODE environment variable set to keycloak because I can see in the output it goes woth default option (uaa):

running RabbitMQ with Idp uaa and configuration file conf/uaa/rabbitmq.config