Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jinyoungbang
Copy link
Contributor

What does this PR do?

  • Created a decorate to easily implement role-based route protection
  • Utilized JWT for checking auth from and to client & server

Type of change

  • Fix: Bug fix (non-breaking change which fixes an issue)
  • Refactor: Any code refactoring
  • Chore: technical debt, workflow improvements
  • Feature: New feature (non-breaking change which adds functionality)
  • Documentation: This change requires a documentation update
  • Merge: Pushing features to an upper envrironment

Tests Performed

Screenshots

Additional Comments

@jinyoungbang jinyoungbang changed the base branch from main to dev/v1.0 March 4, 2024 01:24
@github-actions
Copy link

github-actions bot commented Mar 5, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1063 916 86% 80% 🟢

New Files

File Coverage Status
chalicelib/models/roles.py 100% 🟢
TOTAL 100% 🟢

Modified Files

File Coverage Status
chalicelib/api/applicants.py 100% 🟢
chalicelib/api/insights.py 100% 🟢
chalicelib/api/listings.py 89% 🟢
chalicelib/api/members.py 88% 🟢
chalicelib/decorators.py 81% 🟢
tests/api/test_applicants.py 100% 🟢
tests/api/test_insights.py 100% 🟢
tests/api/test_listings.py 100% 🟢
TOTAL 95% 🟢

updated for commit: 37294b8 by action🐍

@jinyoungbang jinyoungbang marked this pull request as ready for review March 5, 2024 22:17
Args:
blueprint (object): The Chalice Blueprint object, providing access to the current request.
role (list[str]): The required role for authorization.
Copy link

@szou00 szou00 Mar 7, 2024

Choose a reason for hiding this comment

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

should 'role' in the args description be plural ?

Copy link

Choose a reason for hiding this comment

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

i did not know decorator functions was a thing ... very cool and useful 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be roles 🥲

)["Parameter"]["Value"]
decoded = jwt.decode(token, auth_secret, algorithms=["HS256"])
print(roles)
# TODO: if decoded role is not part of given, reject auth
Copy link

@szou00 szou00 Mar 7, 2024

Choose a reason for hiding this comment

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

omg i thought i was being silly bc i couldn't figure out where u were actually doing something with the roles but looks like it's a to-do. i'm assuming you're probably going to finish this up and i'll do another review (to my ability) when u r done ?

@jinyoungbang jinyoungbang requested a review from szou00 March 7, 2024 23:05
@jinyoungbang jinyoungbang merged commit c77878b into dev/v1.0 Mar 10, 2024
@jinyoungbang jinyoungbang added breaking change Breaking Changes feature New Features labels Jul 9, 2024
@jinyoungbang jinyoungbang deleted the feat/protected-routes branch January 21, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Breaking Changes feature New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants