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

Support for multiple Roles #25

Open
10 tasks
gkama opened this issue Aug 2, 2021 · 0 comments
Open
10 tasks

Support for multiple Roles #25

gkama opened this issue Aug 2, 2021 · 0 comments
Assignees
Labels
aiof auth aiof-auth microservice specific enhancement New feature or request
Milestone

Comments

@gkama
Copy link
Member

gkama commented Aug 2, 2021

Overview
Add support for multiple roles for a user in the JWT. This will include a database changes - schema, etc.

For example, the roles object in the JWT should look like this

{
  "iss": "https://www.jerriepelser.com",
  "aud": "blog-readers",
  "sub": "123456",
  "exp": 1499863217,
  "roles": [ "Admin", "SuperUser" ]
}

Use it as [Authorize(Roles = "")]

public class ValuesController : Controller
{
    [Authorize(Roles = "Admin")]
    [HttpGet("ping/admin")]
    public string PingAdmin()
    {
        return "Pong";
    }
}

Current
The User and Client entities have a RoleId reference (as a foreign key) to the Role entity. This is a one-to-one relationship

Solution
Remove the current relationship between the User, Client and Role entities. Create 2 new entities - UserRole and ClientRole. These will store a one-to-many relationship between a UserId / ClientId and RoleId

Task breakdown
When all tasks are completed, then this will reach the definition of done

  • Create separate UserRole entity that stores UserId and RoleId. Foreign keys from User and Role entities
  • Create separate ClientRole entity that stores ClientId and RoleId. Foreign keys from Client and Role entities
  • Populate UserRole and ClientRole entities and PostgreSQL tables
  • Add functionality to get the many roles stored in the entities
  • Add those claims in the JWT generation and is returned to the end-user
  • Feature flag?
  • Remove RoleId from User entity
  • Remove RoleId from Client entity
  • Add / update unit tests
  • Perform integration tests
@gkama gkama added enhancement New feature or request aiof auth aiof-auth microservice specific labels Aug 2, 2021
@gkama gkama added this to the v1 milestone Aug 2, 2021
@gkama gkama self-assigned this Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aiof auth aiof-auth microservice specific enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant