Skip to content
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

Add OpenID configuration in install page #2276

Merged
merged 11 commits into from
Aug 19, 2017

Conversation

strk
Copy link
Member

@strk strk commented Aug 8, 2017

Allows enabling OpenID signin via installation page GUI

@strk strk force-pushed the install-time-openid-config branch 2 times, most recently from d003d54 to b6ca8d9 Compare August 8, 2017 09:33
@strk strk changed the title [WIP] Add OpenID configuration in install page Add OpenID configuration in install page Aug 8, 2017
@strk
Copy link
Member Author

strk commented Aug 8, 2017

This needs be merged before 1.2.0 is out - but there's still a problem with routes depending on the configuration and the configuration being changed by install page but not being re-read upon changing it... So it takes re-starting gitea to be able to register first user via OpenID. I've to figure out how to do the settings update from form submission

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 8, 2017
@strk
Copy link
Member Author

strk commented Aug 8, 2017

I think the fix here is to always define the route but then return a Forbidden status if the service is not enabled

@strk
Copy link
Member Author

strk commented Aug 8, 2017

Ready for merge, tested locally.

@strk
Copy link
Member Author

strk commented Aug 8, 2017

@cweiske you might be interested in testing this too. It basically adds a way to configure OpenID at installation time (was missing, so it took manual intervention to enable it)

Copy link
Member

@lafriks lafriks left a comment

Choose a reason for hiding this comment

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

You have enabled all openid routes but added check that openid is enabled only in two of them

@strk
Copy link
Member Author

strk commented Aug 8, 2017 via email

@lunny
Copy link
Member

lunny commented Aug 8, 2017

@strk CI failed.

@@ -29,6 +29,11 @@ const (
func SignInOpenID(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("sign_in")

if ! setting.Service.EnableOpenIDSignIn {
Copy link
Member

@lafriks lafriks Aug 8, 2017

Choose a reason for hiding this comment

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

CI is failing because of space after ! in multiple places

@strk
Copy link
Member Author

strk commented Aug 8, 2017 via email

Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost)
m.Group("/openid", func() {
m.Combo("/connect").
Get(user.ConnectOpenID).
Copy link
Member

Choose a reason for hiding this comment

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

ConnectOpenID is still missing check if EnableOpenIDSignIn is enabled

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, any pre-requisite settings should be checked in the route-setup, not the route-handler 🙂

}

m.Group("/openid", func() {
m.Combo("").Get(user.SettingsOpenID).
Copy link
Member

Choose a reason for hiding this comment

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

SettingsOpenID is still missing check if EnableOpenIDSignIn is enabled

@@ -40,6 +40,12 @@ func SettingsOpenID(ctx *context.Context) {

// SettingsOpenIDPost response for change user's openid
func SettingsOpenIDPost(ctx *context.Context, form auth.AddOpenIDForm) {

if !setting.Service.EnableOpenIDSignUp {
Copy link
Member

Choose a reason for hiding this comment

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

I think there should be check for EnableOpenIDSignIn not for EnableOpenIDSignUp that is for new user registration

@@ -132,6 +138,10 @@ func settingsOpenIDVerify(ctx *context.Context) {

// DeleteOpenID response for delete user's openid
func DeleteOpenID(ctx *context.Context) {
if !setting.Service.EnableOpenIDSignUp {
Copy link
Member

Choose a reason for hiding this comment

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

There should also be check for EnableOpenIDSignIn

@@ -146,6 +156,10 @@ func DeleteOpenID(ctx *context.Context) {

// ToggleOpenIDVisibility response for toggle visibility of user's openid
func ToggleOpenIDVisibility(ctx *context.Context) {
if !setting.Service.EnableOpenIDSignUp {
Copy link
Member

Choose a reason for hiding this comment

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

And there also should be check for EnableOpenIDSignIn

@strk
Copy link
Member Author

strk commented Aug 9, 2017

@lafriks please see ed9ade1d
To be honest for the settings we might not even check...

@@ -41,6 +41,8 @@ type InstallForm struct {
OfflineMode bool
DisableGravatar bool
EnableFederatedAvatar bool
EnableOpenIDSignIn bool
DisableOpenIDRegistration bool
Copy link
Member

Choose a reason for hiding this comment

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

I'd rather have these both as EnableFoo since it makes more sense when reading

Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost)
m.Group("/openid", func() {
m.Combo("/connect").
Get(user.ConnectOpenID).
Copy link
Member

Choose a reason for hiding this comment

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

Agreed, any pre-requisite settings should be checked in the route-setup, not the route-handler 🙂

@strk
Copy link
Member Author

strk commented Aug 11, 2017 via email

@strk
Copy link
Member Author

strk commented Aug 16, 2017

@bkcsoft do you really want to hold this PR back due to the enable vs. disable wording ?

@strk strk force-pushed the install-time-openid-config branch 2 times, most recently from bf01ca3 to e11db5b Compare August 16, 2017 09:10
@strk
Copy link
Member Author

strk commented Aug 16, 2017

@bkcsoft I've renamed Disable to Enable, as you requested. And rebased to master.
@lafriks I think I've handled your requests too.

@strk strk force-pushed the install-time-openid-config branch from e11db5b to b83addc Compare August 16, 2017 09:21
@strk
Copy link
Member Author

strk commented Aug 16, 2017

actually, the change was partial, more changes were needed around, so I reverted it.

@strk
Copy link
Member Author

strk commented Aug 16, 2017

latest commits fix the handling of checkboxes and turn openid sign-in on by default for new installs

@strk
Copy link
Member Author

strk commented Aug 16, 2017

And for @bkcsoft now I've also turned the "OpenID Registration" form into an "enable" rather than "disable". Also added more javascript to check/uncheck dependents...

@lafriks
Copy link
Member

lafriks commented Aug 17, 2017

As for consideration it would probably be better as @bkcsoft recommended to create new handler/filter to check if openid signin/signup is enabled. Something like this:
https://github.com/go-gitea/gitea/blob/master/routers/routes/routes.go#L336

@strk strk force-pushed the install-time-openid-config branch from a6336e1 to fd66feb Compare August 18, 2017 14:27
@strk
Copy link
Member Author

strk commented Aug 18, 2017

Can we get this merged before 1.2.0 please ? Aesthetic changes can happen in a second step, for now it's important for the functionality to be there.

@lafriks
Copy link
Member

lafriks commented Aug 18, 2017

I'm not against it, @bkcsoft?

@lafriks
Copy link
Member

lafriks commented Aug 18, 2017

BTW don't write LG-TM in comments for your own PR ;) otherwise I see LG-TM 1 label

@strk
Copy link
Member Author

strk commented Aug 18, 2017

Sorry about that, I thought it was fixed (definitely a bug, isn't it ?) - I wasn't seeing the label when I wrote the next comment, btw. Now I see it.

@lunny
Copy link
Member

lunny commented Aug 19, 2017

@strk it was fixed I remember.

@strk
Copy link
Member Author

strk commented Aug 19, 2017

@lunny so it was not deployed?
Anyway, can you review this PR or at least mark it as targeted to 1.2?

@lunny
Copy link
Member

lunny commented Aug 19, 2017

@strk I don't think it's necessary for add this config to installation on v1.2 since LDAP, OAuth and SMTP didn't add to the page. And I think a middleware to check is better than so many settings check on the route functions.

@strk strk force-pushed the install-time-openid-config branch from fd66feb to 34b9bee Compare August 19, 2017 10:28
@strk
Copy link
Member Author

strk commented Aug 19, 2017

Ok now that master branch is fixed I've rebased and also committed a change using filters as suggested in previous comment. @bkcsoft can you please review and merge or at least label as targetted at 1.2.0

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

@strk please fix formatting issues (see Drone)

@strk
Copy link
Member Author

strk commented Aug 19, 2017 via email

@lafriks
Copy link
Member

lafriks commented Aug 19, 2017

LG-TM

@bkcsoft
Copy link
Member

bkcsoft commented Aug 19, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 19, 2017
@bkcsoft bkcsoft merged commit 2c3a229 into go-gitea:master Aug 19, 2017
@strk strk deleted the install-time-openid-config branch August 19, 2017 15:41
@lunny lunny added this to the 1.2.0 milestone Aug 20, 2017
@lunny lunny added the type/enhancement An improvement of existing functionality label Aug 25, 2017
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants