aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-27 02:02:01 +0100
committerGitHub <noreply@github.com>2021-09-26 21:02:01 -0400
commit7e98cd58dd670fd83c0ace5e9c8ef9a0407fd575 (patch)
treed6a7158517d666f7865540c5d350a48abcb2a72f /services
parent74542ad35bae2195972df86862da43e8d45f425f (diff)
downloadgitea-7e98cd58dd670fd83c0ace5e9c8ef9a0407fd575.tar.gz
gitea-7e98cd58dd670fd83c0ace5e9c8ef9a0407fd575.zip
Add SkipLocal2FA option to pam and smtp sources (#17078)
* Add SkipLocal2FA option to other pam and smtp sources Extend #16954 to allow setting skip local 2fa on pam and SMTP authentication sources Signed-off-by: Andrew Thornton <art27@cantab.net> * make SkipLocal2FA omitempty Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'services')
-rw-r--r--services/auth/source/ldap/source.go2
-rw-r--r--services/auth/source/oauth2/source.go2
-rw-r--r--services/auth/source/pam/source.go5
-rw-r--r--services/auth/source/pam/source_authenticate.go5
-rw-r--r--services/auth/source/smtp/source.go1
-rw-r--r--services/auth/source/smtp/source_authenticate.go5
6 files changed, 16 insertions, 4 deletions
diff --git a/services/auth/source/ldap/source.go b/services/auth/source/ldap/source.go
index 82ff7313b2..3d02be4dc9 100644
--- a/services/auth/source/ldap/source.go
+++ b/services/auth/source/ldap/source.go
@@ -53,7 +53,7 @@ type Source struct {
GroupFilter string // Group Name Filter
GroupMemberUID string // Group Attribute containing array of UserUID
UserUID string // User Attribute listed in Group
- SkipLocalTwoFA bool // Skip Local 2fa for users authenticated with this source
+ SkipLocalTwoFA bool `json:",omitempty"` // Skip Local 2fa for users authenticated with this source
// reference to the loginSource
loginSource *login.Source
diff --git a/services/auth/source/oauth2/source.go b/services/auth/source/oauth2/source.go
index 49bb9a0148..60845e3b0f 100644
--- a/services/auth/source/oauth2/source.go
+++ b/services/auth/source/oauth2/source.go
@@ -25,7 +25,7 @@ type Source struct {
OpenIDConnectAutoDiscoveryURL string
CustomURLMapping *CustomURLMapping
IconURL string
- SkipLocalTwoFA bool
+ SkipLocalTwoFA bool `json:",omitempty"`
// reference to the loginSource
loginSource *login.Source
diff --git a/services/auth/source/pam/source.go b/services/auth/source/pam/source.go
index 0bfa7cdb06..73850cd9a2 100644
--- a/services/auth/source/pam/source.go
+++ b/services/auth/source/pam/source.go
@@ -19,8 +19,9 @@ import (
// Source holds configuration for the PAM login source.
type Source struct {
- ServiceName string // pam service (e.g. system-auth)
- EmailDomain string
+ ServiceName string // pam service (e.g. system-auth)
+ EmailDomain string
+ SkipLocalTwoFA bool `json:",omitempty"` // Skip Local 2fa for users authenticated with this source
// reference to the loginSource
loginSource *login.Source
diff --git a/services/auth/source/pam/source_authenticate.go b/services/auth/source/pam/source_authenticate.go
index ad6fbb5cce..cb5ffc2861 100644
--- a/services/auth/source/pam/source_authenticate.go
+++ b/services/auth/source/pam/source_authenticate.go
@@ -69,3 +69,8 @@ func (source *Source) Authenticate(user *models.User, userName, password string)
return user, nil
}
+
+// IsSkipLocalTwoFA returns if this source should skip local 2fa for password authentication
+func (source *Source) IsSkipLocalTwoFA() bool {
+ return source.SkipLocalTwoFA
+}
diff --git a/services/auth/source/smtp/source.go b/services/auth/source/smtp/source.go
index 487375c304..52e2505670 100644
--- a/services/auth/source/smtp/source.go
+++ b/services/auth/source/smtp/source.go
@@ -27,6 +27,7 @@ type Source struct {
SkipVerify bool
HeloHostname string
DisableHelo bool
+ SkipLocalTwoFA bool `json:",omitempty"`
// reference to the loginSource
loginSource *login.Source
diff --git a/services/auth/source/smtp/source_authenticate.go b/services/auth/source/smtp/source_authenticate.go
index f50baa56a2..f51c884c3a 100644
--- a/services/auth/source/smtp/source_authenticate.go
+++ b/services/auth/source/smtp/source_authenticate.go
@@ -85,3 +85,8 @@ func (source *Source) Authenticate(user *models.User, userName, password string)
return user, nil
}
+
+// IsSkipLocalTwoFA returns if this source should skip local 2fa for password authentication
+func (source *Source) IsSkipLocalTwoFA() bool {
+ return source.SkipLocalTwoFA
+}