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

Adding Dynamic Guzzle Config loading #16

Closed MatthewHallCom closed 4 years ago

MatthewHallCom commented 4 years ago

Adds loading a dynamic Guzzle config object from your Keycloak Web config.

Primary use case for this is if you're doing local development and need to disable SSL verification.

Also a light refactor of how Guzzle is imported and bumping to latest stable Guzzle

mariovalney commented 4 years ago

Hey! How are you? Thanks for your contributtion.

Just a question: which Laravel version did you test?

MatthewHallCom commented 4 years ago

@mariovalney 7.4! Happy to give it a run through on an older version if you would like

mariovalney commented 4 years ago

Actually I was just curious to know it's working on new versions. I wasn't able to check until now. :)

I guess we can merge. Would mind to add configuration to docs (README)? Maybe a link to Guzzle docs too.

MatthewHallCom commented 4 years ago

@mariovalney Yup works great! We're using it to secure Laravel Nova on Laravel 7. We also took your idea of the KeycloakUser model and re-factored it for API use too :)

Pushed now with an updated README! Just added it to the FAQ rather than the main config docs, I think it's a pretty rare use case for people.

Also - if you're OK with it I am going to do another PR that re-factors how getOpenIdConfiguration gets called. Right now its being called on every app boot even if theres no Auth or Guards included. I'd like to move it so it only gets loaded when the openid values are actually needed.

mariovalney commented 4 years ago

I don't intend to be boring haha but I think we should explicit any configuration in config file, even if it's trivial (I forgot to mention it before). This way user who exports config from package will find it easily.

In config/keycloak-web.php (after _cacheopenid):

   /**
     * GuzzleHttp Client options
     *
     * @link http://docs.guzzlephp.org/en/stable/request-options.html
     */
    'guzzle_options' => [],

In README.md change: "Just add the options you would like as an array to the" to "Just add the options you would like to guzzle_options array on keycloak-web.php config file. For example:"

Thanks again!

mariovalney commented 4 years ago

We're using it to secure Laravel Nova on Laravel 7. We also took your idea of the KeycloakUser model and re-factored it for API use too

Very happy to read that :) We created ours with InfyOm Laravel Generator. Still want to check Nova someday...

If you're OK with it I am going to do another PR that re-factors how getOpenIdConfiguration gets called. Right now its being called on every app boot even if theres no Auth or Guards included. I'd like to move it so it only gets loaded when the openid values are actually needed.

Sounds perfect for me! We use Keycloak for every route here but you are right it's not necessary the normal use. Great improvement.

MatthewHallCom commented 4 years ago

@mariovalney Your package, your choice! :) Moved over now to be that way!

Also - I am not sure what your level of Keycloak expertise is but we're looking to pay someone for an hour of their time for some Keycloak consulting. Emails on my profile if you're interested. We've got a more complex use case and just want to make sure we're making the right decisions

mariovalney commented 4 years ago

Your package, your choice! :)

haha it's not like this... always open to conversation

Also - I am not sure what your level of Keycloak expertise is but we're looking to pay someone for an hour of their time for some Keycloak consulting. Emails on my profile if you're interested. We've got a more complex use case and just want to make sure we're making the right decisions

We are working with Keycloak for a not-so-complex case but we had to create some providers on Java and a lot of problems on infra.

Anyway I'm not sure I can help somehow but yes! we can chat.

mariovalney commented 4 years ago

v1.5.4 is live :)