forked from motiv-labs/janus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
43 lines (36 loc) · 925 Bytes
/
provider.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package basic
import (
"net/http"
jwt "github.com/dgrijalva/jwt-go"
"github.com/hellofresh/janus/pkg/config"
"github.com/hellofresh/janus/pkg/jwt/provider"
)
func init() {
provider.Register("basic", &Provider{})
}
// Provider abstracts the authentication for github
type Provider struct {
provider.Verifier
}
// Build acts like the constructor for a provider
func (gp *Provider) Build(config config.Credentials) provider.Provider {
return &Provider{
Verifier: provider.NewVerifierBasket(
NewPasswordVerifier(userConfigToTeam(config.Basic.Users)),
),
}
}
// GetClaims returns a JWT Map Claim
func (gp *Provider) GetClaims(httpClient *http.Client) (jwt.MapClaims, error) {
return jwt.MapClaims{}, nil
}
func userConfigToTeam(configUser map[string]string) []*user {
users := []*user{}
for u, p := range configUser {
users = append(users, &user{
Username: u,
Password: p,
})
}
return users
}