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

Implement user check and start of permissions #683

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Conversation

dmtrek14
Copy link
Collaborator

@dmtrek14 dmtrek14 commented Sep 27, 2023

Closes #682 and is an initial implementation of permissions for the API.

  • Add get_current_user to dependencies that introspects token and builds user info based on username in token
  • Add config values to indicate use of OIDC roles (passed in token) or roles in local db
  • Add the user dependency to template endpoints and check user id against logged in user
  • Update user models and schema as needed
  • Add user service to get users and user roles
  • Move Depends(BearerToken()) up to entire timelog router so it no longer needs to be added to each endpoint

Code for the user check based on the examples shown in https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/.

api/routers/v1/timelog.py Outdated Show resolved Hide resolved
api/routers/v1/timelog.py Outdated Show resolved Hide resolved
api/routers/v1/timelog.py Outdated Show resolved Hide resolved
api/routers/v1/timelog.py Outdated Show resolved Hide resolved
api/routers/v1/timelog.py Outdated Show resolved Hide resolved
api/routers/v1/timelog.py Outdated Show resolved Hide resolved
.env.example Outdated Show resolved Hide resolved
- Add get_current_user to dependencies that introspects token and builds user info based on username in token
- Add config values to indicate use of OIDC roles (passed in token) or roles in local db
- Add the user dependency to template endpoints and check user id against logged in user
- Update user models and schema as needed
- Add user service to get users and user roles
Copy link
Member

@anarute anarute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, thank you for the changes!

@dmtrek14 dmtrek14 merged commit 259af3c into main Sep 27, 2023
1 check passed
@dmtrek14 dmtrek14 deleted the api-check-current-user branch September 27, 2023 18:49
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

Successfully merging this pull request may close these issues.

Add basic permission checking in API
2 participants