konrms's avatar

Shibboleth Authentication

I am trying to add the shibboleth authentication package to my project. My laravel version is 5.7.26. I have followed these instructions https://packagist.org/packages/uabookstores/laravel-shibboleth?fbclid=IwAR1fBHLv_0EPgS2hhNc5fB2AVF_ZjOthpPVu_yCgLzySfLYXX-dRSTucCBc but I can not implement users login (and have not understood how to use it).

I'm stuck at this point:

@if (Auth::guest())
    <a href="/shibboleth-login">Login</a>
@else
    <a href="/shibboleth-logout">
        Logout {{ Auth::user()->name }}
    </a>
@endif
0 likes
15 replies
prasadchinwal5's avatar

Hey @konrms I might be too late but I use this package everyday. Could you be more specific in describing your issue. I might be able to help you.

Laravelista's avatar

Hi @prasadchinwal5, do you have any idea if this package would work on lumen 5.5 ? I need to authenticate users that access a pure Vue frontend via Shibboleth. But the backend is made in lumen 5.5.

prasadchinwal5's avatar

Hey @diegones,

So we do have authentication set up for our Vue apps but it uses the OIDC approach. Here is the library we use oidc client.

I actually ended up building the frontend app using nuxt so to integrate it with vuex I used this library vuex oidc client.

You would not be able to authenticate your frontend using the uabookstores/laravel-shibboleth package as your vue app would only be making api calls to your lumen app. So to authenticate your frontend use the oidc client and to authenticate the backend api's use the token introspection method with this package on your lumen app laravel token introspection.

konrms's avatar

Hello @prasadchinwal5 ! Thank you so much, I'm very glad someone replied after 8 months :)

Well 8 months ago, I had implemented a shibboleth emulation for my laravel site. Since then I've been working for other projects, but in the end I should use this package when the site goes live.

Let me explain what I want to do; So far I have created the laravel site on my windows pc and tested it with xampp apache server. Last month I built a CENTOS server and transferred my laravel site to it. The necessary modifications were done and LAN users can access the server visiting my site. We are still testing it, but later we want to add some authentication via shibboleth.

The organization has webmail and users have username & password. Is it possible to allow access to specific organization users using shibboleth? We would like the usernames and passwords used to be pooled from the organization users credentials.

Thank you a lot!!

prasadchinwal5's avatar

@konrms Thanks for the information. Sounds like this is exactly what we do. We authenticate all our users (students/faculty/staff) via shibboleth.

We use this package https://github.com/uabookstores/laravel-shibboleth to achieve this. Steps:

  1. Have a shibboleth configuration(mapping of shibboleth entities)
  2. Install the package and migrate.
  3. Add your configuration to config/shibboleth.php file in your laravel application. (Holds info about redirect after authentication/ add fields to User model etc.)
  4. Add the routes to your web.php file.

Done. If you are facing issues in any of the above steps, let me know.

konrms's avatar

Hi @prasadchinwal5 When I will be close to releasing the site to live state, I hope you will be available to assist me a little with shibboleth!

Thank you VERY much for you help!

konrms's avatar

Hi @prasadchinwal5 !

Well, it seems the time to put server into production environment has come. The laravel project is installed on our server (I haven't added shibboleth package yet on it).

However, as mentioned in previous post, I have installed shibboleth with Shibalike emulation on my windows laptop laravel project, following https://github.com/uabookstores/laravel-shibboleth guide and secured (with success) a desired route by applying the following excerpt inside the corresponding blade

@if (Auth::guest())
    <a href="/shibboleth-login">Login</a>
@else
    <a href="/shibboleth-logout">
        Logout {{ Auth::user()->name }}
    </a>
@endif

Now, regarding the server, I guess I should add shibboleth package omitting the steps for shibalike emulation. How should I edit config/shibboleth.php for existing organization users? Is just this needed for users to be prompted for their individual authentication credentials when trying to open the specific link?

Thank you a lot!

prasadchinwal5's avatar

@konrms Yes, absolutely correct. All you have to do for production server is install the package and edit config/shibboleth.php file as per your need.

Example: You may want to map your server variables with your laravel application User model.

'user' => [
        // fillable user model attribute => server variable
        'name' => 'your_name_variable_from_server',
        'email' => 'your_email_variable_from_server',
        'first_name' => 'your_firstname_variable_from_server',
        'last_name' => 'your_lastname_variable_from_server',
        'custom_field' => 'custom variable',
    ],

These are the fields I have specified in my users migration. The existing users in your organization would be greeted with your shib login page and on successful login they should be redirected to the redirect route specified in your config/shibboleth.php file.

    'authenticated' => '/',
Tinxuanna's avatar

@prasadchinwal5 I am facing the same issue.

I have added in the web.php file the Routes of the Shibboleth package. What I get when I click Login is the below url : https://project.test:80/Shibboleth.sso/Login?target=http://project.test/shibboleth-authenticate

"This site can’t provide a secure connection project.test sent an invalid response. Try running Windows Network Diagnostics. ERR_SSL_PROTOCOL_ERROR"

It is trying to redirect me to the /authenticate page with no success. Any ideas how to fix this??

I also need to map my server variables with the laravel application User model. How can I achieve this in detail?

prasadchinwal5's avatar

@Tinxuanna Hey, hope I am not too late to reply to this issue. Let's tackle the ssl issue. I think your redirect url doesn't include https so you would always get ssl error from shib server. This is because it must be configured to only send redirects to secure urls. So in your case the redirect url https://project.test:80/Shibboleth.sso/Login?target=http://project.test/shibboleth-authenticate should contain https after the target.

The second issue of mapping your server variables from shib to the package is very simple. You will find a config/shibboleth.php. In this file all you need to do is find the user array (Not the one under emulate_idp_users) and set the name of the server variable. Ex.

'entitlement' => 'isMemberOf',

    'user' => [
        // fillable user model attribute => server variable
        'name' => 'cn', // cn is the name returned from my shib server
        'email' => 'mail',
        'first_name' => 'givenName',
        'last_name' => 'sn',
        'uin' => 'UIN',
    ],

Hope this is helpful.

1 like
Tinxuanna's avatar

@prasadchinwal5 Thank you in advance for your answer. I will try to follow your tips and come back with a question if necessary.

1 like
jschlies's avatar

I am trying to implement auth packages uabookstores/laravel-shibboleth and mrclay/shibalike however I need to implement uabookstores/laravel-shibboleth on PHP8.2 but install fails due to the composer.json restrictions of uabookstores/laravel-shibboleth.

Before I fork or search for other solution, can anyone offer guidance?

Please or to participate in this conversation.