-
Notifications
You must be signed in to change notification settings - Fork 81
add oauth #31
base: master
Are you sure you want to change the base?
add oauth #31
Conversation
|
Thanks! This adds oauth with Slack? Is it finished? |
|
@tedeling this add OAuth2 capability to it. I have deployed internally and started using it. Sorry I had to add a few things unrelated. I can find some time later on to clean up and open another pull request. If you want to test, here is my config file: So I tested with two OAuth providers: slack & dex, they all implements the standard OAuth2.0 |
|
Yes if could split the unrelated additions in another PR, that would be great. |
|
|
||
| @NotNull | ||
| @Column(name = "USERNAME", length = 64) | ||
| @Column(name = "USERNAME", length = 1024) |
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 are they so lengthy, oauth standard? The datamodel needs changes as well to accommodate the longer username.
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.
Hi, this change is for when login with oauth, I have to set the username to the email as that's the only reliable field that comes with the claims that is readable. It's probably not necessary to set it to something readable, for example use the "subject" claim. I was trying to let the user able to login with their emails as well after logged in with Oauth the first time.
So I think we should remove this change.
jackielii
left a comment
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.
In general this PR needs a bit improvement to handle different oauth servers, at least make it less error prone.
My comments are the ones I think you can take on. However, I really don't have time to move it forward at the moment.
Hope this helps if some one really needs a oauth adapter.
BTW, my oauth claims response handling is based on slack
| <artifactId>eHour-common</artifactId> | ||
| <type>test-jar</type> | ||
| </dependency> | ||
| <!--<dependency>--> |
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.
this is excluded because somehow if there the docker build won't pass
| <query name="Project.findAllProjectsForCustomers"> | ||
| FROM Project prj | ||
| WHERE prj.customer IN (:customers) | ||
| <!--WHERE prj.customer IN (:customers)--> |
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.
this is a temporary workaround, the customers if empty will generate invalid SQL. didn't have time to look into it
| FROM Project prj | ||
| WHERE prj.customer IN (:customers) AND | ||
| WHERE | ||
| <!--prj.customer IN (:customers) AND--> |
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.
same workaround as above
| <scope>test</scope> | ||
| <classifier>tests</classifier> | ||
| </dependency> | ||
| <!--<dependency>--> |
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.
same reason about the docker build
| <scope>test</scope> | ||
| <classifier>tests</classifier> | ||
| </dependency> | ||
| <!--<dependency>--> |
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.
same reason about the docker build
| <scope>test</scope> | ||
| <classifier>tests</classifier> | ||
| </dependency> | ||
| <!--<dependency>--> |
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.
same reason about the docker build
| RequiredTextField<String> usernameField = new RequiredTextField<>("user.username"); | ||
| form.add(usernameField); | ||
| usernameField.add(new StringValidator(0, 32)); | ||
| usernameField.add(new StringValidator(0, 1024)); |
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.
if this needs to be reverted. then the oauth create user logic needs to be updated
|
|
||
| JSONObject jsonResponse = new JSONObject(result); | ||
|
|
||
| boolean success = jsonResponse.getBoolean("ok"); |
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.
this bit should be re-examined. different oauth server returns different response. in OIDC case, it doesn't return "ok" in response
| u = new User(); | ||
| u.setLastName(name); | ||
| u.setEmail(email); | ||
| u.setUsername(email); |
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.
this needs changing, if signing in only with Oauth, then probably should use subject as username
No description provided.