fix config
This commit is contained in:
parent
8742029109
commit
59fb6e047d
3 changed files with 7 additions and 8 deletions
|
@ -27,16 +27,15 @@ type Authenticator interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type authenticator struct {
|
type authenticator struct {
|
||||||
domain string
|
jwt *jwtauth.JWTAuth
|
||||||
jwt *jwtauth.JWTAuth
|
cfg config.Auth
|
||||||
cfg *config.Auth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewAuthenticator creates a new Authenticator with the provided config.
|
// NewAuthenticator creates a new Authenticator with the provided config.
|
||||||
func NewAuthenticator(cfg *config.Auth) Authenticator {
|
func NewAuthenticator(cfg config.Auth) Authenticator {
|
||||||
return &authenticator{
|
return &authenticator{
|
||||||
domain: cfg.Domain,
|
jwt: jwtauth.New("HS256", []byte(cfg.JWTSecret), nil),
|
||||||
jwt: jwtauth.New("HS256", []byte(cfg.JWTSecret), nil),
|
cfg: cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ func (a *authenticator) routeAuth(w http.ResponseWriter, r *http.Request) {
|
||||||
Value: tok,
|
Value: tok,
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: a.allowInsecureCookie(r),
|
Secure: a.allowInsecureCookie(r),
|
||||||
Domain: a.domain,
|
Domain: a.cfg.Domain,
|
||||||
})
|
})
|
||||||
|
|
||||||
jr := struct {
|
jr := struct {
|
||||||
|
|
|
@ -30,7 +30,7 @@ func New(cfg *config.Config) (*Server, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
authenticator := auth.NewAuthenticator(&cfg.Auth)
|
authenticator := auth.NewAuthenticator(cfg.Auth)
|
||||||
srv := &Server{
|
srv := &Server{
|
||||||
auth: authenticator,
|
auth: authenticator,
|
||||||
conf: cfg,
|
conf: cfg,
|
||||||
|
|
Loading…
Reference in a new issue