mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Merge remote-tracking branch 'upstream/master' into 170621_jobservice
This commit is contained in:
commit
f40bdd2ea1
@ -16,6 +16,7 @@ package secret
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/vmware/harbor/src/common/secret"
|
"github.com/vmware/harbor/src/common/secret"
|
||||||
|
"github.com/vmware/harbor/src/common/utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SecurityContext implements security.Context interface based on secret store
|
// SecurityContext implements security.Context interface based on secret store
|
||||||
@ -35,9 +36,15 @@ func NewSecurityContext(secret string, store *secret.Store) *SecurityContext {
|
|||||||
// IsAuthenticated returns true if the secret is valid
|
// IsAuthenticated returns true if the secret is valid
|
||||||
func (s *SecurityContext) IsAuthenticated() bool {
|
func (s *SecurityContext) IsAuthenticated() bool {
|
||||||
if s.store == nil {
|
if s.store == nil {
|
||||||
|
log.Debug("secret store is nil")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return s.store.IsValid(s.secret)
|
valid := s.store.IsValid(s.secret)
|
||||||
|
if !valid {
|
||||||
|
log.Debugf("invalid secret: %s", s.secret)
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUsername returns the corresponding username of the secret
|
// GetUsername returns the corresponding username of the secret
|
||||||
|
@ -50,7 +50,7 @@ func Init() {
|
|||||||
// integration with admiral
|
// integration with admiral
|
||||||
if config.WithAdmiral() {
|
if config.WithAdmiral() {
|
||||||
reqCtxModifiers = []ReqCtxModifier{
|
reqCtxModifiers = []ReqCtxModifier{
|
||||||
&secretReqCtxModifier{},
|
&secretReqCtxModifier{config.SecretStore},
|
||||||
&tokenReqCtxModifier{},
|
&tokenReqCtxModifier{},
|
||||||
&unauthorizedReqCtxModifier{}}
|
&unauthorizedReqCtxModifier{}}
|
||||||
return
|
return
|
||||||
@ -58,7 +58,7 @@ func Init() {
|
|||||||
|
|
||||||
// standalone
|
// standalone
|
||||||
reqCtxModifiers = []ReqCtxModifier{
|
reqCtxModifiers = []ReqCtxModifier{
|
||||||
&secretReqCtxModifier{},
|
&secretReqCtxModifier{config.SecretStore},
|
||||||
&basicAuthReqCtxModifier{},
|
&basicAuthReqCtxModifier{},
|
||||||
&sessionReqCtxModifier{},
|
&sessionReqCtxModifier{},
|
||||||
&unauthorizedReqCtxModifier{}}
|
&unauthorizedReqCtxModifier{}}
|
||||||
|
Loading…
Reference in New Issue
Block a user