XavRsl / Cas

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

Where to use Cas::authenticate(); ? #41

Closed bmendonca closed 7 years ago

bmendonca commented 7 years ago

Hello there!

I'm new to Laravel and using this Cas add-in and was wondering from where Cas::authenticate(); should be called? Should it be called from routes only or can it be called within controller methods as well? Some examples would be much appreciated. Thanks so much and have a nice day!

at0dd commented 7 years ago

Hey Brian, If you want, I have an example repository with just Laravel and XacRsl/Cas installed. https://github.com/at0dd/laravel-cas/ If you take a look at routes/web.php there are some basic login/logout routes which call functions in app/Http/Controllers/Auth/AuthController.php and app/Http/Middleware/CASAuthenticate.php Feel free to email me if you have any more questions.

XavRsl commented 7 years ago

Hi,

Thanks @at0dd, your example repo is great. And thank you for responding so quickly !

Xavier

bmendonca commented 7 years ago

Thanks @at0dd ! I'm working on setting up the same changes/config that you used in your example (it's very helpful so far), however I do notice that AuthController.php throws an error in the __contruct() method, specifically: Call to undefined method App\Http\Controllers\Auth\AuthController::middleware()

I'll keep trying to see if I can figure out what's going on.

bmendonca commented 7 years ago

Thanks again for your assistance @at0dd ! It seems that my Laravel project had something wrong with it, possibly from upgrading from an earlier version some time ago. Anyway, I took your example files as a new project and then merged my project's Controllers/Routes/etc. into it and it looks like I'm reaching the point where everything is working now (at least as far as using the .env variable CAS_PRETEND_USER goes). It looks like I'm out of the woods! Have a nice day!