fix config

This commit is contained in:
Daniel 2024-08-04 09:07:31 -04:00
parent 8742029109
commit 59fb6e047d
3 changed files with 7 additions and 8 deletions

View file

@ -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,
} }
} }

View file

@ -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 {

View file

@ -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,