Skip to content

Commit

Permalink
Use utlis function to void nil pointer panics
Browse files Browse the repository at this point in the history
Co-authored-by: kobergj <[email protected]>
  • Loading branch information
rhafer and kobergj committed May 24, 2022
1 parent 0eea228 commit 40b484a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions extensions/graph/pkg/middleware/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cs3org/reva/v2/pkg/auth/scope"
revactx "github.com/cs3org/reva/v2/pkg/ctx"
"github.com/cs3org/reva/v2/pkg/token/manager/jwt"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/owncloud/ocis/v2/extensions/graph/pkg/service/v0/errorcode"
"github.com/owncloud/ocis/v2/ocis-pkg/account"
opkgm "github.com/owncloud/ocis/v2/ocis-pkg/middleware"
Expand Down Expand Up @@ -74,10 +75,8 @@ func Auth(opts ...account.Option) func(http.Handler) http.Handler {
ctx = revactx.ContextSetToken(ctx, t)
ctx = revactx.ContextSetUser(ctx, u)
ctx = gmmetadata.Set(ctx, opkgm.AccountID, u.Id.OpaqueId)
if u.Opaque != nil {
if roles, ok := u.Opaque.Map["roles"]; ok {
ctx = gmmetadata.Set(ctx, opkgm.RoleIDs, string(roles.Value))
}
if role := utils.ReadPlainFromOpaque(u.Opaque, "roles"); role != "" {
ctx = gmmetadata.Set(ctx, opkgm.RoleIDs, role)
}
ctx = metadata.AppendToOutgoingContext(ctx, revactx.TokenHeader, t)

Expand Down

0 comments on commit 40b484a

Please sign in to comment.