@@ -6,6 +6,7 @@ package user
6
6
7
7
import (
8
8
"fmt"
9
+ "net/http"
9
10
"net/url"
10
11
11
12
"code.gitea.io/gitea/models"
@@ -250,7 +251,7 @@ func signInOpenIDVerify(ctx *context.Context) {
250
251
log .Error ("signInOpenIDVerify: Unable to save changes to the session: %v" , err )
251
252
}
252
253
253
- if u != nil || ! setting .Service .EnableOpenIDSignUp {
254
+ if u != nil || ! setting .Service .EnableOpenIDSignUp || setting . Service . AllowOnlyInternalRegistration {
254
255
ctx .Redirect (setting .AppSubURL + "/user/openid/connect" )
255
256
} else {
256
257
ctx .Redirect (setting .AppSubURL + "/user/openid/register" )
@@ -268,6 +269,7 @@ func ConnectOpenID(ctx *context.Context) {
268
269
ctx .Data ["PageIsSignIn" ] = true
269
270
ctx .Data ["PageIsOpenIDConnect" ] = true
270
271
ctx .Data ["EnableOpenIDSignUp" ] = setting .Service .EnableOpenIDSignUp
272
+ ctx .Data ["AllowOnlyInternalRegistration" ] = setting .Service .AllowOnlyInternalRegistration
271
273
ctx .Data ["OpenID" ] = oid
272
274
userName , _ := ctx .Session .Get ("openid_determined_username" ).(string )
273
275
if userName != "" {
@@ -329,6 +331,7 @@ func RegisterOpenID(ctx *context.Context) {
329
331
ctx .Data ["PageIsSignIn" ] = true
330
332
ctx .Data ["PageIsOpenIDRegister" ] = true
331
333
ctx .Data ["EnableOpenIDSignUp" ] = setting .Service .EnableOpenIDSignUp
334
+ ctx .Data ["AllowOnlyInternalRegistration" ] = setting .Service .AllowOnlyInternalRegistration
332
335
ctx .Data ["EnableCaptcha" ] = setting .Service .EnableCaptcha
333
336
ctx .Data ["Captcha" ] = context .GetImageCaptcha ()
334
337
ctx .Data ["CaptchaType" ] = setting .Service .CaptchaType
@@ -368,6 +371,11 @@ func RegisterOpenIDPost(ctx *context.Context) {
368
371
ctx .Data ["HcaptchaSitekey" ] = setting .Service .HcaptchaSitekey
369
372
ctx .Data ["OpenID" ] = oid
370
373
374
+ if setting .Service .AllowOnlyInternalRegistration {
375
+ ctx .Error (http .StatusForbidden )
376
+ return
377
+ }
378
+
371
379
if setting .Service .EnableCaptcha {
372
380
var valid bool
373
381
var err error
0 commit comments