XavRsl / Cas

CAS server SSO authentication in Laravel 4.x & 5.x
MIT License
77 stars 36 forks source link

How do you append the service when loging out a user #31

Closed demonmind closed 8 years ago

demonmind commented 8 years ago

I call Cas::logout() and the users logs out but the url of the SSO server does not have the service parameter with it. How do i add the service url to logout so the url becomes the same as when i login?

XavRsl commented 8 years ago

Here's an example :

Cas::logout(['service' => url('/')]);
demonmind commented 8 years ago

I get this error

phpCAS error: phpCAS::logoutWithRedirectService(): type mismatched for parameter $service (should be `string')

demonmind commented 8 years ago

This worked Cas::logout(url('/'));

Thanks

XavRsl commented 8 years ago

:+1:

demonmind commented 8 years ago

@XavRsl is there a way i can create user if the user is not found in the local app, but it is found in the cas-server?

I am referring to something like this:

https://github.com/Fnatte/laravel-cas/blob/master/src/Teuz/LaravelCas/Cas.php#L159

XavRsl commented 8 years ago

I put this in a Middleware like that :

public function handle($request, Closure $next)
    {
        Cas::authenticate();

        if (!Auth::check()) {
            Auth::login(
                CasUser::register(Cas::user())
            );
        }

        return $next($request);
    }

And my CasUser class looks like :

class CasUser
{

    public static function register($login)
    {
        if ($user = User::where('login', $login)->first())
        {
            return $user;
        }

        return User::create([
            'login' => $login,
            'name' => Ldap::people($login)->displayname,
            'email' => Ldap::people($login)->mail
        ]);
    }
}