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

Ability to pull resource and resource scopes #60

Closed socieboy closed 2 years ago

socieboy commented 2 years ago

Before anything thank you for this package, it's been such a great help to not start from scratch my laravel app integration with Keycloak.

As much as I play with Keycloak I found the awesome things we can do, the package is great so far but i think we are missing one part that this pull-request adds, and it's the ability to delegate to Keycloak the authorization, Policy and permissions that a user can have to access a resource.

With the pull request we can extract the authenticated user resources and scopes.

By simple calling

KeycloakWeb::authorizations();

We will get a response like this:

[
  {
    "name": "Posts Page",
    "scopes": [
      "view",
      "create",
      "update",
      "destroy"
    ]
  },
  {
    "name": "Users Page",
    "scopes": [
      "view",
      "create",
      "update",
      "destroy"
    ]
  }
]

More information about this can be found on the keycloak doc: https://www.keycloak.org/docs/latest/authorization_services/index.html#_service_overview

mariovalney commented 2 years ago

As I told you in #59: I'm sorry for taking time to review it. Why did you closed it?

socieboy commented 2 years ago

@mariovalney I'm working a little bit more, cleaning the changes i made and refactoring the code, plus i want to update the README with instructions to use some new methods.

mariovalney commented 2 years ago

Cool. I'm happy you didn't give up the PR because my delay. :)

Merry Christmas by the way.