-
Notifications
You must be signed in to change notification settings - Fork 19
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
WIP - Documentation #21
Conversation
push: | ||
branches: | ||
- master | ||
- documentation # @todo Remove this before merging PR. |
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.
Reminder: This needs to be removed before PR is merged.
Added for the sake of building documentation on Github throughout the development of this pull request.
@synchronizing wow very impressive! many thanks for contributing! |
Plug-and-Play | ||
============= | ||
|
||
aioauth was designed to be as flexible as possible to allow developers to choose their own server framework, as well as database provider. Since aioauth is written as an asynchronous module it would be to the advantage of the developer to write their applications asynchronously. |
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.
great explanation!
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.
@synchronizing wow very impressive! many thanks for contributing!
My pleasure on the contribution. I see the huge potential this library has, and I think documentation this early on would help flourishing the repo down the line. I have future plans to eventually helping out implementing OpenID Connect as well.
great explanation!
Thank you! I'm writing things as I go, so if you feel like anything is out-of-line, please don't hesitate to call it out/change it. I'll be working on this further come the this month (likely in a few weeks)- I got a huge deadline dropped on my table yesterday.
@synchronizing I had no apparent reason to replace str with Text. I think Text doesn't make sense for models, but maybe it makes sense to use it for Request / Response classes fields only? Note from the python docs:
in any case I see no problem in replacing Text with str. What do you think about that? |
I agree with the replacement.
I agree with the use of unicode there - a lot of databases do support unicode, and I can certainly see the use for websites/providers that leverage different characters for their usernames/passwords. Will replace the |
Unsure why last commit is throwing line errors from Running |
@synchronizing could you try
|
No cigar on my end. Unsure why. 10:13:16 at /Users/felipe/Desktop/aioauth
λ black .
All done! ✨ 🍰 ✨
31 files left unchanged.
10:13:18 at /Users/felipe/Desktop/aioauth
λ git status
On branch documentation
Your branch is up to date with 'origin/documentation'.
nothing to commit, working tree clean Really weird. Will explore further, but your response was super helpful - likely some weird settings is getting applied for my Black formatter. Thank you. |
@synchronizing hmm that's interesting. I cloned your fork, created virtual environment based on python 3.8:
and did this what flake8 command shows:
|
@@ -123,6 +143,18 @@ async def validate_request(self, request: Request) -> Client: | |||
|
|||
|
|||
class PasswordGrantType(GrantTypeBase): | |||
""" | |||
The Password grant type is a way to exchange a user's credentials |
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.
@synchronizing should we remove the PasswordGrantType
from the BaseAuthorizationServer
by default?
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.
I would advise against removing assuming I understand the question correctly - which would mean removing PasswordGrantType
completely. Forgive me if you meant something else.
Password grant, while not recommended for every client, is the preferred method for those that separate their backend and frontend (also called, "first-party" apps, since the OAuth server owner also owns another application that leverages the server). In other words, if you have a FastAPI OAuth server and a seperate React frontend and mobile app, the only realistic way to have the user login is via the PasswordGrantType
. To put it into perspective, you login to Twitter on their iOS app and React frontend via the PasswordGrantType
, but login to (say) External Application X via their AuthorizationCodeGrantType
, where the OAuth server asks "hey, you sure you want to authorize this app?" See here for more info.
While I haven't gotten to checking this just yet in relation to aioauth
, one thing that authorization servers must have is the ability to specify which grant type a specific client has access to. Company A might have a OAuth server and frontend and mobile app that leverages the PasswordGrantType
, while also allowing company B to use their OAuth server, but only have access to the AuthorizationCodeGrantType
. See here for more info.
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.
no, I did not mean complete deletion, as this is part of the oauth2 protocol. I thought about excluding it by default from BaseAuthorizationServer:
aioauth/src/aioauth/base/server.py
Lines 25 to 28 in 188699e
GrantType.TYPE_AUTHORIZATION_CODE: AuthorizationCodeGrantType, | |
GrantType.TYPE_CLIENT_CREDENTIALS: ClientCredentialsGrantType, | |
GrantType.TYPE_PASSWORD: PasswordGrantType, | |
GrantType.TYPE_REFRESH_TOKEN: RefreshTokenGrantType, |
user can still enable it with the register method:
aioauth/src/aioauth/base/server.py
Lines 34 to 41 in 188699e
def register( | |
self, | |
endpoint_type: EndpointType, | |
server: Union[ResponseType, GrantType], | |
endpoint_cls: Union[Type[ResponseTypeBase], Type[GrantTypeBase]], | |
): | |
endpoint_dict = getattr(self, endpoint_type) | |
endpoint_dict[server] = endpoint_cls |
but in any case, the user can also remove the PasswordGrantType on his own :)
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.
Oh, I see!
I'm in favor, in such case. I haven't gotten to documenting the base server just yet, so I didn't know that function even existed. We can document this properly and ensure users are aware that there is the option, even though it's not recommended. Whatever the case, I wouldn't be making the modifications via this PR since it's exclusive to documentation, but I can add to the docs as soon as we make that change.
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.
Indeed. Better to just document it and user will decide should it remove it or keep it
@synchronizing interesting, the build status is still waiting. |
I think it is due to a bad merge from my end (master to documentation). Going to try to figure this out today and continue work on the PR. |
Fixed the merge conflict, and Black situation. For future references, for whatever reason my system was defaulting to the latest version of Black (global install) despite activating the virtual environment. Running the |
|
||
code_challenge_method: Optional[CodeChallengeMethod] = None | ||
""" | ||
Only used when `RFC 7636 <tools.ietf.org/html/rfc7636>`_, |
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.
@synchronizing
I think the link here must be also with http(s) prefix: https://synchronizing.github.io/aioauth/sections/documentation/models.html#aioauth.models.AuthorizationCode.code_challenge_method (otherwise it leads to the current path)
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.
Sphinx wasn't playing nice at the time, and adding https://
was (surprisingly enough) breaking the hyperlink. Without it seemed to work, but I'll go ahead and leave this review open to go over this before finalizing things - I'll try to make https
work.
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
- Coverage 99.27% 98.92% -0.36%
==========================================
Files 15 15
Lines 549 556 +7
Branches 56 56
==========================================
+ Hits 545 550 +5
- Misses 3 4 +1
- Partials 1 2 +1
Continue to review full report at Codecov.
|
@@ -48,8 +48,8 @@ clean-test: ## remove test and coverage artifacts | |||
rm -fr .pytest_cache | |||
|
|||
lint: ## check style with flake8 | |||
flake8 src/aioauth tests | |||
pyright src/aioauth tests | |||
flake8 aioauth tests |
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.
@synchronizing I'm thinking about removing the flake8
and black
from the requirements and use only pre-commit.
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.
Makes sense to me. I have to revisit the project soon- things took an unexpected turn in life. Whatever is changed in master I'll apply to this branch in time.
Closing this for the meantime. Planning on restarting this PR some point in the next few months. If new PR is created regarding docs, any text written here can be utilized. |
Work in progress (WIP), please do not merge.
Effort to add documentation to the entire project. Any feedback is welcomed.
Todo
root/src/<project>
folder for the more conventionalroot/<project>
format.Getting Started
,Plug & Play
,Settings
, andIndex
documentation.Contributing
to documentation.Makefile
./examples
folder with the complete code, as well as the documentation page on the logic of the example code.Note
This PR adds auto documentation publishing to the
gh-pages
, which automatically publishes the docs at<user>.github.io/aioauth/
. See example here. This must be turned on in the repo settings.Misc
Fix for #16, #22.
Update for #23.