Skip to content

Commit

Permalink
fix JWT authorizer to use the correct key
Browse files Browse the repository at this point in the history
  • Loading branch information
demdxx committed Jun 17, 2024
1 parent a4fc00a commit 708a152
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions example/api/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,6 @@ func main() {
Logger: loggerObj,
JWTProvider: jwtProvider,
SessionManager: appinit.SessionManager(conf.Session.CookieName, conf.Session.Lifetime),
// OAuth2provider: oauth2provider,
// AuthOption: gocast.IfThen(conf.IsDebug(), &middleware.AuthOption{
// DevToken: conf.Session.DevToken,
// DevUserID: conf.Session.DevUserID,
// DevAccountID: conf.Session.DevAccountID,
// }, nil),
Authorizers: []auth.Authorizer{
jwt.NewAuthorizer(jwtProvider),
oauth2.NewAuthorizer(oauth2provider),
Expand Down
4 changes: 2 additions & 2 deletions pkg/auth/jwt/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ func (au *Authorizer) AuthorizerCode() string {
}

func (au *Authorizer) Authorize(w http.ResponseWriter, r *http.Request) (token string, usr *model.User, acc *model.Account, err error) {
ctx := r.Context()
if err = au.jmid.CheckJWT(w, r); err != nil {
ctxlogger.Get(ctx).Debug("JWT authorization", zap.Error(err))
ctxlogger.Get(r.Context()).Debug("JWT authorization", zap.Error(err))
return "", nil, nil, nil
}

ctx := r.Context()
jwtToken := ctx.Value(au.jmid.Options.UserProperty)
switch t := jwtToken.(type) {
case nil:
Expand Down

0 comments on commit 708a152

Please sign in to comment.