codemation / easyauth

Create a centralized Authentication and Authorization token server. Easily secure FastAPI endpoints based on Users, Groups, Roles or Permissions with very little database usage.
https://easyauth.readthedocs.io/en/latest/
MIT License
553 stars 52 forks source link

"/groups" not working #79

Closed pedrocavadas closed 1 year ago

pedrocavadas commented 1 year ago

Hi! After the update, I managed to get my test server and client working, so I tried creating a test service to check if I could make the requests properly, but stumbled across the error "{"detail":"not authorized, permissions required: {'groups': ['users', 'admins']}"}" when trying the /groups endpoint. It's probably some mistake on my side, so I was wondering if anyone could help me out.

Here are the steps I followed:

  1. Start both test server and client
  2. Create a service named "test service"
  3. Assign "test service" to "administrators" group
  4. Generate a token for "test service"
  5. Grab the token generated and insert it on the request header: curl -X GET http://:/groups -H 'Content-Type: application/json' -H 'Authorization: Bearer '

Am I missing something?

codemation commented 1 year ago

The error indicates the problem I think:

"{"detail":"not authorized, permissions required: {'groups': ['users', 'admins']}"}"

The route was probably decorated with groups=["users", "admins"], if you want to allow access, then "administrators" needs to be in the the decorated list as well.

codemation commented 1 year ago

@pedrocavadas solve your problem?

pedrocavadas commented 1 year ago

Sorry, I forgot to reply here. Yes, it did solve it, thank you sou much.