Closed sascha284 closed 4 years ago
It is just a example of return value. Just changed README to avoid confusion.
Auth::hasRole('myapp-backend', 'myapp-backend-role1') // true
Auth::hasRole('myapp-frontend', 'myapp-frontend-role1') // true
Auth::hasRole('myapp-backend', 'myapp-frontend-role1') // false
@robsontenorio Tudo bom? Espero que sim! Cara esse pacote está me servindo, mas tem uma coisa que me incomoda um pouco nessa funcionalidade.
É complesxo para que funcione com multiplas validações, ex: Usuário tem 'operador' e 'gestor' como papeis definidos no Keycloak.
Auth::hasRole('myapp-backend', 'gestor', 'admin') // true Auth::hasRole('myapp-backend', 'gestor') // true Auth::hasRole('myapp-backend', 'operador', 'admin' ) // true Auth::hasRole('myapp-backend', 'admin' ) // false
@robsontenorio Everything good? I hope so! Man, this package is serving me, but there is something that bothers me a little about this functionality.
It is complex to work with multiple validations, ex: User has 'operator' and 'manager' as roles defined in Keycloak.
Auth::hasRole('myapp-backend', 'manager', 'admin') // true Auth::hasRole('myapp-backend', 'manager') // true Auth::hasRole('myapp-backend', 'operator', 'admin' ) // true Auth::hasRole('myapp-backend', 'admin' ) // false
@luizjr you are looking for hasAnyRole
that not exists. Are you able to send a PR with proper tests?
I can try, we'll see if I can
@robsontenorio I just created a pull request to implement this function.
https://github.com/robsontenorio/laravel-keycloak-guard/pull/88
@robsontenorio I've updated the pull request, I think it should meet expectations well. https://github.com/robsontenorio/laravel-keycloak-guard/pull/88
Thanks for this great solution! It works realy nice. Just have one problem. I tried:
Auth::hasRole('SuperUser') => true
and also insertuse Illuminate\Contracts\Auth\Guard;
But it returned me a syntax error (unexpected '=>' (T_DOUBLE_ARROW). I am also using realm roles. Is Auth::hasRole checking this, too?