-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Implement Route Protection through JWT #41
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d746ca
feat: implement route protection through JWT
jinyoungbang a522aa9
chore: add docstring comments
jinyoungbang e5144a2
chore: edit docstring
jinyoungbang 73a09f8
refactor: utilize chalice built-in exception
jinyoungbang 5fb3370
refactor: implement auth on unit tests
jinyoungbang 6ecab03
refactor: use enums on role-based auth
jinyoungbang 37294b8
chore: fix spelling err
jinyoungbang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,29 @@ | ||
| from chalice import Blueprint | ||
| from chalicelib.services.ApplicantService import applicant_service | ||
| from chalicelib.handlers.error_handler import handle_exceptions | ||
| from chalicelib.decorators import auth | ||
| from chalicelib.models.roles import Roles | ||
|
|
||
| from pydantic import ValidationError | ||
|
|
||
| applicants_api = Blueprint(__name__) | ||
|
|
||
|
|
||
| @applicants_api.route("/applicant/{id}", methods=["GET"], cors=True) | ||
| @auth(applicants_api, roles=[Roles.ADMIN, Roles.MEMBER]) | ||
| def get_applicant(id): | ||
| """Get an applicant from <applicant_id>""" | ||
| return applicant_service.get(id) | ||
|
|
||
|
|
||
| @applicants_api.route("/applicants", methods=["GET"], cors=True) | ||
| @auth(applicants_api, roles=[Roles.ADMIN, Roles.MEMBER]) | ||
| def get_applicants(): | ||
| return applicant_service.get_all() | ||
|
|
||
|
|
||
| @applicants_api.route("/applicants/{listing_id}", methods=["GET"], cors=True) | ||
| @auth(applicants_api, roles=[Roles.ADMIN, Roles.MEMBER]) | ||
| def get_all_applicants(listing_id): | ||
| """Gets all applicants from <listing_id>""" | ||
| return applicant_service.get_all_from_listing(listing_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,12 @@ | ||
| from chalice import Blueprint | ||
| from chalicelib.services.MemberService import member_service | ||
| from chalicelib.decorators import auth | ||
|
|
||
| members_api = Blueprint(__name__) | ||
|
|
||
|
|
||
| @members_api.route("/members", methods=["GET"], cors=True) | ||
| @auth(members_api, roles=["admin", "member"]) | ||
| def get_all_members(): | ||
| """Get an applicant from <applicant_id>""" | ||
| return member_service.get_all() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from enum import Enum | ||
|
|
||
|
|
||
| class Roles(Enum): | ||
| ADMIN = "admin" | ||
| MEMBER = "member" | ||
| # Add more roles as needed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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 ?