-
-
Notifications
You must be signed in to change notification settings - Fork 470
Expand file tree
/
Copy pathsecurity.go
More file actions
26 lines (21 loc) · 592 Bytes
/
Copy pathsecurity.go
File metadata and controls
26 lines (21 loc) · 592 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package utils
import (
"time"
log "github.com/sirupsen/logrus"
)
type SecurityConfig struct {
AccessTokenExpiration time.Duration
Secret []byte
UserAuthHeader string
}
func (c SecurityConfig) IsRemoteAuth() bool {
return c.UserAuthHeader != ""
}
func GetSecurityConfig(accessTokenExp string, secret []byte) (SecurityConfig, error) {
exp, err := time.ParseDuration(accessTokenExp)
if err != nil {
log.WithError(err).Error("issue parsing duration")
return SecurityConfig{}, err
}
return SecurityConfig{AccessTokenExpiration: exp, Secret: secret}, nil
}