mariovalney / laravel-keycloak-web-guard

Simple Keycloak Guard to Laravel Web Routes - https://packagist.org/packages/vizir/laravel-keycloak-web-guard
146 stars 80 forks source link

How to get login URL? #8

Closed RewardRepo closed 4 years ago

RewardRepo commented 4 years ago

Hi,

I have some problem to configure the framework. How can I configure the login form?

I follow you readme but now I don't know how to authenticate the user.

Thanks Mattia

mariovalney commented 4 years ago

Hi, Mattia. How are you?

You will not use [your] login form.

Following the readme you will get a "login URL" which will redirect the user to Keycloak login page.

RewardRepo commented 4 years ago

Hi Matio,

Thanks for the response! Yes, sorry We have the login form in our keycloack server but I don't know how to redirect the authentication.

Thanks, Mattia

mariovalney commented 4 years ago

If you protected a route, the user will be redirected to login.

If you want the link to login (or another page) just use: route('keycloak.login');.

I hope this can help you.

rickcwlng-hc commented 4 years ago

Hi,

I'm currently trying to implement the package, but after I login I'm encountering and error. It redirects me too many times. What do you think is the issue?

Thank you for the amazing package!

mariovalney commented 4 years ago

@rickcwlng-hc I moved your comment to a new issue. Let's work there, ok? :)

RewardRepo commented 4 years ago

Thanks for the response. Last question, how can I retrive the user information when I come back from the login form? Our server response is a JWT.

Thanks, Mattia

mariovalney commented 4 years ago

You don't need to do this.

This package take care of persist session and you can use the Auth Guard methods like regular laravel login.

Anyway, you can use the Vizir\KeycloakWebGuard\Facades\KeycloakWeb facade and retrieveToken method.

RewardRepo commented 4 years ago

Using KeycloakWeb::retrieveToken(); or Auth::user() the result is always null

mariovalney commented 4 years ago

So, token was not stored on session.

Check Keycloak is redirecting to callback after login, please.

RewardRepo commented 4 years ago

Hi,

yes, in url I have "redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Fcallback."

RewardRepo commented 4 years ago

In function retrieveToken() I have the correct token but the return of the function is null

RewardRepo commented 4 years ago

I resolved the issue:

I changed the SESSION_DRIVER from "cookie" to "native"

mariovalney commented 4 years ago

Hi. There's no "native" SESSION_DRIVER.

Maybe, using "native" (which is invalid) Laravel uses "file" driver.

I'll check it's all OK with "cookie" session, but it's recommended to use "file" anyway because will work well for the majority of applications.

mariovalney commented 4 years ago

Closing because sounds like everything is OK.

If you have any problem, please not hesitate to create a new issue.

Thanks.