oktadev / okta-kong-origin-example

Kong Gateway Example with OIDC and Okta
https://developer.okta.com/blog/2017/12/04/use-kong-gateway-to-centralize-authentication
44 stars 22 forks source link

Extracting user details from x-userinfo header #8

Closed ABHINAVPRIYADARSHI closed 5 years ago

ABHINAVPRIYADARSHI commented 5 years ago

I am using this plugin to authenticate. It works actually fine and I am even getting x-userinfo header passed on to Spring boot as: x-userinfo': 'eyJ3ZWJzaXRlIjoiaHR0cHM6XC9cL3d3dy5waW5naWRlbnRpdHkuY29tXC8iLCJpZCI6IkFkbWluaXN0cmF0b3IiLCJsb2NhbGUiOiJlbl9VUyIsImdpdmVuX25hbWUiOiJNYXJ5IiwicHJvZmlsZSI6Imh0dHBzOlwvXC93d3cucGluZ2lkZW50aXR5LmNvbVwvcHJvZHVjdHNcL3BpbmdmZWRlcmF0ZVwvIiwic3ViIjoiQWRtaW5pc3RyYXRvciIsImJpcnRoZGF0ZSI6IjE5NzctMTItMzEiLCJuaWNrbmFtZSI6Ik5hbWUiLCJuYW1lIjoiTWFyeSBHb29kIFNhbXBsZSIsInVzZXJuYW1lIjoibWdzYW1wbGUiLCJmYW1pbHlfbmFtZSI6IlNhbXBsZSIsInVwZGF0ZWRfYXQiOiIyMDExLTAxLTAzVDIzOjU4OjQyKzAwMDAiLCJwaWN0dXJlIjoiaHR0cHM6XC9cL3d3dy5waW5naWRlbnRpdHkuY29tXC9pbWFnZXNcL3BpbmctbG9nby5wbmciLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJtZ3NhbXBsZSIsImdlbmRlciI6ImZlbWFsZSIsIm1pZGRsZV9uYW1lIjoiR29vZCIsInpvbmVpbmZvIjoiQW1lcmljYVwvTmV3X1lvcmsifQ==' }

I am not able to get userinfo in the format as described in plugin's read.md file: X-Userinfo: {"preferred_username":"alice","id":"60f65308-3510-40ca-83f0e9c0151cc680","sub":"60f65308-3510-40ca-83f0-e9c0151cc680"} How can I extract user credentials from this header to customize user experience ?? Thank you