Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will this work with OKTA? #15

Closed
VickG opened this issue Oct 9, 2015 · 11 comments
Closed

will this work with OKTA? #15

VickG opened this issue Oct 9, 2015 · 11 comments

Comments

@VickG
Copy link

VickG commented Oct 9, 2015

I am trying to integrate with https://www.okta.com/

Can I use this library for that purpose?

@aacotroneo
Copy link
Owner

I dont know. This is just a Laravel wrapper for https://github.com/onelogin/php-saml. It they do, we do.

@bronxct1
Copy link

@VickG Yes this will work with OKTA, I have implemented this in a project quite easily

@aacotroneo
Copy link
Owner

thanks @bronxct1 for helping out!

@narbehmovsesi
Copy link

@bronxct1 can you share an example?

@bronxct1
Copy link

I'll have to check if I still have an example. I left the company where I implemented this, but it was quite straightforward after following the initial set up. Basically in the Saml2Listener you will grab the saml user and log them into the Laravel application.

I would be glad to help you out if you are in the Laravel slack

@durancu
Copy link

durancu commented Apr 20, 2017

Hi @bronxct1! Did you find your example? I'm working on this stuff next week an would be good to have an starting point from your experience. Best regards

@bronxct1
Copy link

bronxct1 commented Apr 20, 2017

@durancu This is what I found. It should give you enough to go on.

    /**
     * Handle the event.
     *
     * @param  Saml2LoginEvent  $event
     * @return void
     */
    public function handle(Saml2LoginEvent $event)
    {
        $saml_user = $event->getSaml2User();

        $user = Contributors::where('username', '=', $saml_user->getUserId())->first();

        $attributes = $user->getAttributes();

        if (empty($user)) {
            $user = Contributors::create([
                'username' => $user->getUserId(),
                'email' => $user->getUserId(),
                'first_name' => $attributes['first_name'][0],
                'last_name' => $attributes['last_name'][0]
            ]);

            $user->base()->create([
                'slug' => $user->full_name
            ]);
        }

        if (is_null($user->base)) {
            $user->base()->create([
                'slug' => $user->full_name
            ]);
        }

        if (!$user->hasRole($attributes['role'][0])) {
            $role = Role::where('name', $attributes['role'][0])->first();

            $user->roles()->sync([$role->id]);
        }

        $this->auth->login($user);
    }

@durancu
Copy link

durancu commented Apr 20, 2017

Thank you @bronxct1. I will check it out!

@durancu
Copy link

durancu commented Apr 20, 2017

Sorry, it this code to replace the vendor listener handle function? I'm not sure where it goes.

@BrendanTWhite
Copy link
Contributor

Hi all, there is another project tequilarapido/socialite-okta which might also work for Laravel / Okta. I haven't tried it yet ... I will post back when I've tried it.

@chaseconey
Copy link

This has been implemented into the Socialite community package:
http://socialiteproviders.github.io/providers/okta/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants