Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth::hasRole(...) => true returns unexpected #32

Closed
sascha284 opened this issue Sep 28, 2020 · 6 comments
Closed

Auth::hasRole(...) => true returns unexpected #32

sascha284 opened this issue Sep 28, 2020 · 6 comments

Comments

@sascha284
Copy link

Thanks for this great solution! It works realy nice. Just have one problem. I tried:
Auth::hasRole('SuperUser') => true
and also insert use 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?

@robsontenorio
Copy link
Owner

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

@luizjr
Copy link
Contributor

luizjr commented Mar 24, 2023

@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

Translated

@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

@robsontenorio
Copy link
Owner

@luizjr you are looking for hasAnyRole that not exists. Are you able to send a PR with proper tests?

@luizjr
Copy link
Contributor

luizjr commented Mar 24, 2023

I can try, we'll see if I can

@luizjr
Copy link
Contributor

luizjr commented Mar 25, 2023

@robsontenorio I just created a pull request to implement this function.

#88

@luizjr
Copy link
Contributor

luizjr commented Mar 28, 2023

@robsontenorio I've updated the pull request, I think it should meet expectations well.
#88

@ostri ostri mentioned this issue Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants