Skip to content

Commit

Permalink
Added JWT to context
Browse files Browse the repository at this point in the history
  • Loading branch information
akeemphilbert committed Apr 17, 2024
1 parent 5badbce commit 0bf771e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions rest/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const HeaderXAccountID = "X-Account-ID"
const HeaderXLogLevel = "X-LOG-LEVEL"

// add more keys here if needed
const AUTHORIZATION_HEADER = "AUTHORIZATION_HEADER"
const APPLICATION_ID = "APPLICATION_ID"
const ACCOUNT_ID ContextKey = "ACCOUNT_ID"
const OPERATION_ID = "OPERATION_ID"
Expand Down
2 changes: 2 additions & 0 deletions rest/middlewares.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ func SecurityMiddleware(p *MiddlewareParams) echo.MiddlewareFunc {
newContext = context.WithValue(newContext, ROLE, result.Role)
newContext = context.WithValue(newContext, ACCOUNT_ID, result.AccountID)
newContext = context.WithValue(newContext, APPLICATION_ID, result.ApplicationID)
newContext = context.WithValue(newContext, AUTHORIZATION_HEADER, ctxt.Request().Header.Get("Authorization"))

request := ctxt.Request().WithContext(newContext)
ctxt.SetRequest(request)
//check the scopes of the logged-in user against what is required and if the user doesn't have the required scope deny access
Expand Down

0 comments on commit 0bf771e

Please sign in to comment.