-
Notifications
You must be signed in to change notification settings - Fork 3
/
auth0.go
46 lines (35 loc) · 1.18 KB
/
auth0.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
44
45
46
package auth0
import (
"github.com/alexfalkowski/go-service/security/jwt"
"github.com/alexfalkowski/go-service/transport/http"
"github.com/dgraph-io/ristretto"
"go.uber.org/zap"
)
// NewGenerator for Auth0.
// nolint:ireturn
func NewGenerator(cfg *Config, httpCfg *http.Config, logger *zap.Logger, cache *ristretto.Cache) jwt.Generator {
params := &http.ClientParams{
Config: httpCfg,
Logger: logger,
}
var generator jwt.Generator = &generator{cfg: cfg, client: http.NewClient(params)}
generator = &cachedGenerator{cfg: cfg, cache: cache, Generator: generator}
return generator
}
// NewCertificator for Auth0.
// nolint:ireturn
func NewCertificator(cfg *Config, httpCfg *http.Config, logger *zap.Logger, cache *ristretto.Cache) Certificator {
params := &http.ClientParams{
Config: httpCfg,
Logger: logger,
}
var certificator Certificator = &pem{cfg: cfg, client: http.NewClient(params)}
certificator = &cachedPEM{cfg: cfg, cache: cache, Certificator: certificator}
return certificator
}
// NewVerifier for Auth0.
// nolint:ireturn
func NewVerifier(cfg *Config, cert Certificator) jwt.Verifier {
var verifier jwt.Verifier = &verifier{cfg: cfg, cert: cert}
return verifier
}