Giter Club home page Giter Club logo

Comments (8)

thathoff avatar thathoff commented on August 26, 2024 1

You’re welcome! And it is a common use case indeed! I already thought about having a hook inside the loginUser() (here) method to implement custom modifications to the Kirby user based on the OAuth ResourceOwner.

from kirby-oauth.

thathoff avatar thathoff commented on August 26, 2024 1

Since there is no roadmap for this plug-in I can't add it. But I think this makes the plug-in a lot more flexible this will be the next feature I'm going to implement.

If that's not fast enough for your case or someone else likes to help here: Pull requests are very welcome... 😉

from kirby-oauth.

pReya avatar pReya commented on August 26, 2024

Yeah, I guess a hook basically covers all use cases and is more flexible than hard coding specific user props. Any chance you can put the hook functionality on your roadmap?

from kirby-oauth.

pReya avatar pReya commented on August 26, 2024

What would you suggest the function signature for this hook should look like? What are its parameters?

from kirby-oauth.

thathoff avatar thathoff commented on August 26, 2024

I’m thinking about having a hook that gets the $oauthUser (ResourceOwnerInterface) as a first parameter and the second one is the Kirby user. Then you can modify the user or even implement a gate by throwing an exception to prevent the user login. I’m not sure if it should replace/bypass the whole creation and check logic currently I would say it should be an addition.

from kirby-oauth.

pReya avatar pReya commented on August 26, 2024

I’m not sure if it should replace/bypass the whole creation and check logic currently I would say it should be an addition.

Would probably be nice if this was optional – maybe a config option? Or could this somehow be conifgured/decided within the hook function? Could call the existing login logic inside the hook (if wanted)?

from kirby-oauth.

pReya avatar pReya commented on August 26, 2024

@thathoff In the last year I've learned a lot more about Oauth, and I have an upcoming project, where I need to distinguish users based on their groups in the Identity Provider again.

I have thought about implementing this, but I'm currently a little lost regarding the PHP League Oauth Interface. The interface doesn't have any functions for getting custom claim (like groups) from the token. So even with your suggested hook solution, we'd only have the ResourceOwnerInterface which doesn't offer anything to access custom claims from the token.

from kirby-oauth.

thathoff avatar thathoff commented on August 26, 2024

This depends largely on your Oauth provider. I remember from a project that fetching the groups for a Google user is pretty hard to do. Have you tried to fetch the groups with the $provider->getAuthenticatedRequest() method and maybe an API providing the groups of the user? (see https://oauth2-client.thephpleague.com/usage/ for an example).

from kirby-oauth.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.