diff options
author | haixunlu <luhaixun@gmail.com> | 2018-12-18 12:49:30 -0800 |
---|---|---|
committer | 无闻 <u@gogs.io> | 2018-12-18 15:49:30 -0500 |
commit | 311df9c521f05cdca880152e73dbed47afb74cde (patch) | |
tree | f3b9159e6dc23e6659e1da5939ff7f09d7a32c16 /routes/admin | |
parent | ff93d9dbda5cebe90d86e4b7dfb2c6b8642970ce (diff) |
auth: add new authentication source: GitHub, including GitHub Enterprise (#5340)
* Add new Authentication Source: GitHub, including GitHub Enterprise.
* Add vendor dependencies.
Diffstat (limited to 'routes/admin')
-rw-r--r-- | routes/admin/auths.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/routes/admin/auths.go b/routes/admin/auths.go index d013c793..a217174a 100644 --- a/routes/admin/auths.go +++ b/routes/admin/auths.go @@ -7,15 +7,16 @@ package admin import ( "fmt" + "strings" + "github.com/Unknwon/com" "github.com/go-xorm/core" - log "gopkg.in/clog.v1" - "github.com/gogs/gogs/models" "github.com/gogs/gogs/pkg/auth/ldap" "github.com/gogs/gogs/pkg/context" "github.com/gogs/gogs/pkg/form" "github.com/gogs/gogs/pkg/setting" + log "gopkg.in/clog.v1" ) const ( @@ -51,6 +52,7 @@ var ( {models.LoginNames[models.LOGIN_DLDAP], models.LOGIN_DLDAP}, {models.LoginNames[models.LOGIN_SMTP], models.LOGIN_SMTP}, {models.LoginNames[models.LOGIN_PAM], models.LOGIN_PAM}, + {models.LoginNames[models.LOGIN_GITHUB], models.LOGIN_GITHUB}, } securityProtocols = []dropdownItem{ {models.SecurityProtocolNames[ldap.SECURITY_PROTOCOL_UNENCRYPTED], ldap.SECURITY_PROTOCOL_UNENCRYPTED}, @@ -138,6 +140,10 @@ func NewAuthSourcePost(c *context.Context, f form.Authentication) { config = &models.PAMConfig{ ServiceName: f.PAMServiceName, } + case models.LOGIN_GITHUB: + config = &models.GITHUBConfig{ + ApiEndpoint: f.GithubApiEndpoint, + } default: c.Error(400) return @@ -220,6 +226,14 @@ func EditAuthSourcePost(c *context.Context, f form.Authentication) { config = &models.PAMConfig{ ServiceName: f.PAMServiceName, } + case models.LOGIN_GITHUB: + var apiEndpoint = f.GithubApiEndpoint + if !strings.HasSuffix(apiEndpoint, "/") { + apiEndpoint += "/" + } + config = &models.GITHUBConfig{ + ApiEndpoint: apiEndpoint, + } default: c.Error(400) return |