You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
799 B
34 lines
799 B
4 years ago
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package sso
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"code.gitea.io/gitea/models"
|
||
|
)
|
||
|
|
||
|
// SignedInUser returns the user object of signed user.
|
||
|
// It returns a bool value to indicate whether user uses basic auth or not.
|
||
|
func SignedInUser(req *http.Request, ds DataStore, sess SessionStore) (*models.User, bool) {
|
||
|
if !models.HasEngine {
|
||
|
return nil, false
|
||
|
}
|
||
|
|
||
|
// Try to sign in with each of the enabled plugins
|
||
|
for _, ssoMethod := range Methods() {
|
||
|
if !ssoMethod.IsEnabled() {
|
||
|
continue
|
||
|
}
|
||
|
user := ssoMethod.VerifyAuthData(req, ds, sess)
|
||
|
if user != nil {
|
||
|
_, isBasic := ssoMethod.(*Basic)
|
||
|
return user, isBasic
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return nil, false
|
||
|
}
|