finalist / liferay-oidc-plugin

Plugin for Liferay, enabling OpenID Connect authentication
Apache License 2.0
21 stars 31 forks source link

OAuthProblemException #48

Closed uPagge closed 4 years ago

uPagge commented 4 years ago

Hi

I am trying to configure oauth 2 on liferay version 7.0.6 GA7. Oauth 2 provider I have spring.

I was able to configure provider itself and 2 clients to it to check that I configured provider correctly. Everything worked, clients also on spring boot.

But when I tried to integrate my provider into liferay using your plugin, I encountered the following problem that I can't solve

изображение

изображение

gvanderploeg commented 4 years ago

Hi,

Set the log level of the package nl.finalist.liferay to DEBUG, then you'll see the exact response that the OAuth2 provider sends. Apparently it has another format (or is not 200 OK at all), but you'll only know with logging enabled.

(Control Panel -> Server Administration -> Log levels)

uPagge commented 4 years ago

@gvanderploeg

So I got the code to work. Class LibFilter

изображение

gvanderploeg commented 4 years ago

Hi,

Ok, so basically you added a few specific headers, and an explicit Basic Auth header. Without having delved into the org.apache.oltu.oauth2 code, I would guess that that Basic Auth header is also added by them. And I'm curious what the default Accept and Content-Type headers are when you don't specify them.

uPagge commented 4 years ago

@gvanderploeg Is it possible to convey any additional information about the user? For example, user roles

gvanderploeg commented 4 years ago

There is no construct available in the plugin for this. There is another issue that suggests to make the access token available to portlets but I'm not really happy with that. But you could write a post login action just like any other in Liferay, and then fetch the OIDC details from the session, just like the LibAutoLogin does already:

Map<String, String> userInfo = (Map<String, String>) session.getAttribute(
                LibFilter.OPENID_CONNECT_SESSION_ATTR);