-
Notifications
You must be signed in to change notification settings - Fork 388
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
Implementation of Oauth of Github, Google and Microsoft #4298
base: master
Are you sure you want to change the base?
Conversation
5ce7f18
to
68eaf7b
Compare
de2e213
to
d3f6b29
Compare
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.
Please see my remarks.
I have some additional comments apart from the direct in code messages:
- My major concern with the implementation is that the oauth related API and its implementation is not generalized enough. The configuration is good enough for the time being.
- I am not sure if we are allowed to use the Git Hub logo in our repo.
- Please invite @cservakt to review the JS and VueJS parts.
I did not do a thorough review of the oauth flow in authentication.py
after you addressed the above issues I will do another round concentrating on that.
Thanks for the hard work!
12c68e7
to
f064c2b
Compare
b4d5a0a
to
d3847d6
Compare
…s, commented lines
d107d90
to
fcc5cd5
Compare
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.
Thank you for this development. This is a great and important work!
@@ -16,6 +16,9 @@ Table of Contents | |||
* [<i>LDAP</i> authentication](#ldap-authentication) | |||
* [Configuration options](#configuration-options) | |||
* Membership in custom groups with [<i>regex_groups</i>](#regex_groups-authentication) |
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.
The regex_groups
could be a sub-point like OAuth authentication.
web/api/authentication.thrift
Outdated
// Returns list of providers for oauth for respective appearence of buttons. | ||
list<string> getOauthProviders(), | ||
|
||
// Create a link for the user to log in for github Oauth. |
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.
Not just github.
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.
Fixed, corrected wrong comment
"< DATETIME(\"" + date + "\")") | ||
session.commit() | ||
LOG.info("Expired state, validation codes removed successfully.") | ||
except sqlite3.Error as e: |
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.
Why is it catching only sqlite3 errors? How about other database engines?
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.
Fixed, removed specific catch for sqlite3 and replaced with more general.
|
||
LOG.info("State inserted successfully.") | ||
|
||
except sqlite3.Error as e: |
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.
Why is it catching only sqlite3 errors? How about other database engines?
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.
Fixed, removed specific catch for sqlite3 and replaced with more general.
@timeit | ||
def createLink(self, provider): | ||
""" | ||
For creating a autehntication link for OAuth for specified provider |
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.
For creating a autehntication link for OAuth for specified provider | |
For creating an authentication link for OAuth for specified provider. |
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.
Fixed, reformulated the explanation.
user_info = None | ||
username = None |
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.
Unnecessary initialization.
# if the provider is github it fetches primary email | ||
# from another api endpoint to maintain username as email | ||
# consistency between GitHub and other providers |
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.
What do we use "username" for in CodeChecker? If we want to identify authorized users by their e-mail addresses, then couldn't we use the "email" attribute of their user info? In this case it wouldn't be needed to distinguish GitHub here.
provider_cfg = self.__auth_config.get( | ||
'method_oauth', {}).get("providers", {}).get(provider, {}) | ||
|
||
# turn off configuration if it is set to default values |
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.
What is the purpose of this protection? I would say that examples can be provided in the documentation, but the template config file can have empty values and OAuth method being disabled.
@@ -64,6 +66,10 @@ def setup_class_common(): | |||
|
|||
codechecker.add_test_package_product(host_port_cfg, TEST_WORKSPACE) | |||
|
|||
subprocess.Popen(["python3", "oauth_server.py"], | |||
cwd="tests/functional/authentication") | |||
sleep(5) |
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.
Is this sleep()
operation intended or accidental?
self.last_access = last_access if last_access else datetime.now() | ||
|
||
def get_access_token(self): |
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.
Where is this function used?
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.
not used anywhere yet, just created it in advance to fetch access token.
aa6a37c
to
6bc0652
Compare
d4127c8
to
2452509
Compare
2452509
to
79325da
Compare
fixes #4160
The right way it should look after logging in
![Screenshot from 2024-07-18 17-38-29](https://private-user-images.githubusercontent.com/113597150/350030361-70ae37b7-b60a-48c0-8cf6-48f300fdc417.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODk2NDMsIm5iZiI6MTczOTE4OTM0MywicGF0aCI6Ii8xMTM1OTcxNTAvMzUwMDMwMzYxLTcwYWUzN2I3LWI2MGEtNDhjMC04Y2Y2LTQ4ZjMwMGZkYzQxNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQxMjA5MDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02ODQ5OGEyMjliNmYxNzNlMDJiNThiMjFiZmExZDk1YTI4YmNhYzAzYzkyNjVlN2E0YjY4YjQwM2M2NzgzYTg0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.FlczdbwXJfsfKZTPBXVEKBZPRoDu4uAsJf8xZzUiP7M)
new added button to log in with github
![Screenshot from 2024-07-18 17-40-36](https://private-user-images.githubusercontent.com/113597150/350031270-62d69339-fba0-4fa6-b143-0e666b61656c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxODk2NDMsIm5iZiI6MTczOTE4OTM0MywicGF0aCI6Ii8xMTM1OTcxNTAvMzUwMDMxMjcwLTYyZDY5MzM5LWZiYTAtNGZhNi1iMTQzLTBlNjY2YjYxNjU2Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjEwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIxMFQxMjA5MDNaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMGU5NWQzZmFkOTgzNjA3OTJmZDJkMjQ4MDA1YTZjNmMzNWU2ZmQxMDcxNmZiNTExZTQ4YWFmYmFhZGM5MjA1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.mtVV-xQaOVbuYAQl9Mx6Z5FXCBYpCu4fTfU8G-DvSrE)
Changes: