Add OpenID configuration in install page (#2276)
This commit is contained in:
parent
e7653a67a1
commit
2c3a229a3c
|
@ -41,6 +41,8 @@ type InstallForm struct {
|
||||||
OfflineMode bool
|
OfflineMode bool
|
||||||
DisableGravatar bool
|
DisableGravatar bool
|
||||||
EnableFederatedAvatar bool
|
EnableFederatedAvatar bool
|
||||||
|
EnableOpenIDSignIn bool
|
||||||
|
EnableOpenIDSignUp bool
|
||||||
DisableRegistration bool
|
DisableRegistration bool
|
||||||
EnableCaptcha bool
|
EnableCaptcha bool
|
||||||
RequireSignInView bool
|
RequireSignInView bool
|
||||||
|
|
|
@ -116,6 +116,10 @@ federated_avatar_lookup = Enable Federated Avatars Lookup
|
||||||
federated_avatar_lookup_popup = Enable federated avatar lookup using Libravatar.
|
federated_avatar_lookup_popup = Enable federated avatar lookup using Libravatar.
|
||||||
disable_registration = Disable Self-registration
|
disable_registration = Disable Self-registration
|
||||||
disable_registration_popup = Disable user self-registration, only admin can create accounts.
|
disable_registration_popup = Disable user self-registration, only admin can create accounts.
|
||||||
|
openid_signin = Enable OpenID Sign-In
|
||||||
|
openid_signin_popup = Enable user login via OpenID
|
||||||
|
openid_signup = Enable OpenID Self-registration
|
||||||
|
openid_signup_popup = Enable OpenID based Self-registration
|
||||||
enable_captcha = Enable Captcha
|
enable_captcha = Enable Captcha
|
||||||
enable_captcha_popup = Require a CAPTCHA for user self-registration.
|
enable_captcha_popup = Require a CAPTCHA for user self-registration.
|
||||||
require_sign_in_view = Enable Require Sign In to View Pages
|
require_sign_in_view = Enable Require Sign In to View Pages
|
||||||
|
|
|
@ -311,9 +311,22 @@ function initInstall() {
|
||||||
$('#offline-mode').checkbox('uncheck');
|
$('#offline-mode').checkbox('uncheck');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
$('#enable-openid-signin input').change(function () {
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
if ( $('#disable-registration input').is(':checked') ) {
|
||||||
|
} else {
|
||||||
|
$('#enable-openid-signup').checkbox('check');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#enable-openid-signup').checkbox('uncheck');
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#disable-registration input').change(function () {
|
$('#disable-registration input').change(function () {
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(':checked')) {
|
||||||
$('#enable-captcha').checkbox('uncheck');
|
$('#enable-captcha').checkbox('uncheck');
|
||||||
|
$('#enable-openid-signup').checkbox('uncheck');
|
||||||
|
} else {
|
||||||
|
$('#enable-openid-signup').checkbox('check');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('#enable-captcha input').change(function () {
|
$('#enable-captcha input').change(function () {
|
||||||
|
|
|
@ -108,6 +108,8 @@ func Install(ctx *context.Context) {
|
||||||
form.OfflineMode = setting.OfflineMode
|
form.OfflineMode = setting.OfflineMode
|
||||||
form.DisableGravatar = setting.DisableGravatar
|
form.DisableGravatar = setting.DisableGravatar
|
||||||
form.EnableFederatedAvatar = setting.EnableFederatedAvatar
|
form.EnableFederatedAvatar = setting.EnableFederatedAvatar
|
||||||
|
form.EnableOpenIDSignIn = true
|
||||||
|
form.EnableOpenIDSignUp = true
|
||||||
form.DisableRegistration = setting.Service.DisableRegistration
|
form.DisableRegistration = setting.Service.DisableRegistration
|
||||||
form.EnableCaptcha = setting.Service.EnableCaptcha
|
form.EnableCaptcha = setting.Service.EnableCaptcha
|
||||||
form.RequireSignInView = setting.Service.RequireSignInView
|
form.RequireSignInView = setting.Service.RequireSignInView
|
||||||
|
@ -292,6 +294,8 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
|
||||||
cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode))
|
cfg.Section("server").Key("OFFLINE_MODE").SetValue(com.ToStr(form.OfflineMode))
|
||||||
cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar))
|
cfg.Section("picture").Key("DISABLE_GRAVATAR").SetValue(com.ToStr(form.DisableGravatar))
|
||||||
cfg.Section("picture").Key("ENABLE_FEDERATED_AVATAR").SetValue(com.ToStr(form.EnableFederatedAvatar))
|
cfg.Section("picture").Key("ENABLE_FEDERATED_AVATAR").SetValue(com.ToStr(form.EnableFederatedAvatar))
|
||||||
|
cfg.Section("openid").Key("ENABLE_OPENID_SIGNIN").SetValue(com.ToStr(form.EnableOpenIDSignIn))
|
||||||
|
cfg.Section("openid").Key("ENABLE_OPENID_SIGNUP").SetValue(com.ToStr(form.EnableOpenIDSignUp))
|
||||||
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
|
cfg.Section("service").Key("DISABLE_REGISTRATION").SetValue(com.ToStr(form.DisableRegistration))
|
||||||
cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha))
|
cfg.Section("service").Key("ENABLE_CAPTCHA").SetValue(com.ToStr(form.EnableCaptcha))
|
||||||
cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView))
|
cfg.Section("service").Key("REQUIRE_SIGNIN_VIEW").SetValue(com.ToStr(form.RequireSignInView))
|
||||||
|
|
|
@ -136,6 +136,20 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
bindIgnErr := binding.BindIgnErr
|
bindIgnErr := binding.BindIgnErr
|
||||||
validation.AddBindingRules()
|
validation.AddBindingRules()
|
||||||
|
|
||||||
|
openIDSignInEnabled := func(ctx *context.Context) {
|
||||||
|
if !setting.Service.EnableOpenIDSignIn {
|
||||||
|
ctx.Error(403)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
openIDSignUpEnabled := func(ctx *context.Context) {
|
||||||
|
if !setting.Service.EnableOpenIDSignUp {
|
||||||
|
ctx.Error(403)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m.Use(user.GetNotificationCount)
|
m.Use(user.GetNotificationCount)
|
||||||
|
|
||||||
// FIXME: not all routes need go through same middlewares.
|
// FIXME: not all routes need go through same middlewares.
|
||||||
|
@ -163,19 +177,21 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Group("/user", func() {
|
m.Group("/user", func() {
|
||||||
m.Get("/login", user.SignIn)
|
m.Get("/login", user.SignIn)
|
||||||
m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost)
|
m.Post("/login", bindIgnErr(auth.SignInForm{}), user.SignInPost)
|
||||||
if setting.Service.EnableOpenIDSignIn {
|
m.Group("", func() {
|
||||||
m.Combo("/login/openid").
|
m.Combo("/login/openid").
|
||||||
Get(user.SignInOpenID).
|
Get(user.SignInOpenID).
|
||||||
Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost)
|
Post(bindIgnErr(auth.SignInOpenIDForm{}), user.SignInOpenIDPost)
|
||||||
|
}, openIDSignInEnabled)
|
||||||
m.Group("/openid", func() {
|
m.Group("/openid", func() {
|
||||||
m.Combo("/connect").
|
m.Combo("/connect").
|
||||||
Get(user.ConnectOpenID).
|
Get(user.ConnectOpenID).
|
||||||
Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost)
|
Post(bindIgnErr(auth.ConnectOpenIDForm{}), user.ConnectOpenIDPost)
|
||||||
m.Combo("/register").
|
m.Group("/register", func() {
|
||||||
Get(user.RegisterOpenID).
|
m.Combo("").
|
||||||
|
Get(user.RegisterOpenID, openIDSignUpEnabled).
|
||||||
Post(bindIgnErr(auth.SignUpOpenIDForm{}), user.RegisterOpenIDPost)
|
Post(bindIgnErr(auth.SignUpOpenIDForm{}), user.RegisterOpenIDPost)
|
||||||
})
|
}, openIDSignUpEnabled)
|
||||||
}
|
}, openIDSignInEnabled)
|
||||||
m.Get("/sign_up", user.SignUp)
|
m.Get("/sign_up", user.SignUp)
|
||||||
m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost)
|
m.Post("/sign_up", bindIgnErr(auth.RegisterForm{}), user.SignUpPost)
|
||||||
m.Get("/reset_password", user.ResetPasswd)
|
m.Get("/reset_password", user.ResetPasswd)
|
||||||
|
@ -206,15 +222,12 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Post("/email/delete", user.DeleteEmail)
|
m.Post("/email/delete", user.DeleteEmail)
|
||||||
m.Get("/password", user.SettingsPassword)
|
m.Get("/password", user.SettingsPassword)
|
||||||
m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost)
|
m.Post("/password", bindIgnErr(auth.ChangePasswordForm{}), user.SettingsPasswordPost)
|
||||||
if setting.Service.EnableOpenIDSignIn {
|
|
||||||
m.Group("/openid", func() {
|
m.Group("/openid", func() {
|
||||||
m.Combo("").Get(user.SettingsOpenID).
|
m.Combo("").Get(user.SettingsOpenID).
|
||||||
Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost)
|
Post(bindIgnErr(auth.AddOpenIDForm{}), user.SettingsOpenIDPost)
|
||||||
m.Post("/delete", user.DeleteOpenID)
|
m.Post("/delete", user.DeleteOpenID)
|
||||||
m.Post("/toggle_visibility", user.ToggleOpenIDVisibility)
|
m.Post("/toggle_visibility", user.ToggleOpenIDVisibility)
|
||||||
})
|
}, openIDSignInEnabled)
|
||||||
}
|
|
||||||
|
|
||||||
m.Combo("/keys").Get(user.SettingsKeys).
|
m.Combo("/keys").Get(user.SettingsKeys).
|
||||||
Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost)
|
Post(bindIgnErr(auth.AddKeyForm{}), user.SettingsKeysPost)
|
||||||
m.Post("/keys/delete", user.DeleteKey)
|
m.Post("/keys/delete", user.DeleteKey)
|
||||||
|
|
|
@ -259,6 +259,7 @@ func ConnectOpenID(ctx *context.Context) {
|
||||||
|
|
||||||
// ConnectOpenIDPost handles submission of a form to connect an OpenID URI to an existing account
|
// ConnectOpenIDPost handles submission of a form to connect an OpenID URI to an existing account
|
||||||
func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) {
|
func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) {
|
||||||
|
|
||||||
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
||||||
if oid == "" {
|
if oid == "" {
|
||||||
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
||||||
|
@ -300,10 +301,6 @@ func ConnectOpenIDPost(ctx *context.Context, form auth.ConnectOpenIDForm) {
|
||||||
|
|
||||||
// RegisterOpenID shows a form to create a new user authenticated via an OpenID URI
|
// RegisterOpenID shows a form to create a new user authenticated via an OpenID URI
|
||||||
func RegisterOpenID(ctx *context.Context) {
|
func RegisterOpenID(ctx *context.Context) {
|
||||||
if !setting.Service.EnableOpenIDSignUp {
|
|
||||||
ctx.Error(403)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
||||||
if oid == "" {
|
if oid == "" {
|
||||||
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
||||||
|
@ -328,10 +325,6 @@ func RegisterOpenID(ctx *context.Context) {
|
||||||
|
|
||||||
// RegisterOpenIDPost handles submission of a form to create a new user authenticated via an OpenID URI
|
// RegisterOpenIDPost handles submission of a form to create a new user authenticated via an OpenID URI
|
||||||
func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.SignUpOpenIDForm) {
|
func RegisterOpenIDPost(ctx *context.Context, cpt *captcha.Captcha, form auth.SignUpOpenIDForm) {
|
||||||
if !setting.Service.EnableOpenIDSignUp {
|
|
||||||
ctx.Error(403)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
oid, _ := ctx.Session.Get("openid_verified_uri").(string)
|
||||||
if oid == "" {
|
if oid == "" {
|
||||||
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
ctx.Redirect(setting.AppSubURL + "/user/login/openid")
|
||||||
|
|
|
@ -188,12 +188,24 @@
|
||||||
<input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
|
<input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<div class="ui checkbox" id="enable-openid-signin">
|
||||||
|
<label class="poping up" data-content="{{.i18n.Tr "install.openid_signin_popup"}}"><strong>{{.i18n.Tr "install.openid_signin"}}</strong></label>
|
||||||
|
<input name="enable_open_id_sign_in" type="checkbox" {{if .enable_open_id_sign_in}}checked{{end}}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<div class="ui checkbox" id="disable-registration">
|
<div class="ui checkbox" id="disable-registration">
|
||||||
<label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>
|
<label class="poping up" data-content="{{.i18n.Tr "install.disable_registration_popup"}}"><strong>{{.i18n.Tr "install.disable_registration"}}</strong></label>
|
||||||
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
|
<input name="disable_registration" type="checkbox" {{if .disable_registration}}checked{{end}}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="inline field">
|
||||||
|
<div class="ui checkbox" id="enable-openid-signup">
|
||||||
|
<label class="poping up" data-content="{{.i18n.Tr "install.openid_signup_popup"}}"><strong>{{.i18n.Tr "install.openid_signup"}}</strong></label>
|
||||||
|
<input name="enable_open_id_sign_up" type="checkbox" {{if .enable_open_id_sign_up}}checked{{end}}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="inline field">
|
<div class="inline field">
|
||||||
<div class="ui checkbox" id="enable-captcha">
|
<div class="ui checkbox" id="enable-captcha">
|
||||||
<label class="poping up" data-content="{{.i18n.Tr "install.enable_captcha_popup"}}"><strong>{{.i18n.Tr "install.enable_captcha"}}</strong></label>
|
<label class="poping up" data-content="{{.i18n.Tr "install.enable_captcha_popup"}}"><strong>{{.i18n.Tr "install.enable_captcha"}}</strong></label>
|
||||||
|
|
Loading…
Reference in New Issue