MatchesRequest returns true if the token matches the request. Any token that does not match the request should be considered invalid.
(req Request)
| 32 | // MatchesRequest returns true if the token matches the request. Any token that |
| 33 | // does not match the request should be considered invalid. |
| 34 | func (t SignedToken) MatchesRequest(req Request) bool { |
| 35 | tokenBasePath := t.Request.BasePath |
| 36 | if !strings.HasSuffix(tokenBasePath, "/") { |
| 37 | tokenBasePath += "/" |
| 38 | } |
| 39 | reqBasePath := req.BasePath |
| 40 | if !strings.HasSuffix(reqBasePath, "/") { |
| 41 | reqBasePath += "/" |
| 42 | } |
| 43 | |
| 44 | return t.AccessMethod == req.AccessMethod && |
| 45 | tokenBasePath == reqBasePath && |
| 46 | t.Prefix == req.Prefix && |
| 47 | t.UsernameOrID == req.UsernameOrID && |
| 48 | t.WorkspaceNameOrID == req.WorkspaceNameOrID && |
| 49 | t.AgentNameOrID == req.AgentNameOrID && |
| 50 | t.AppSlugOrPort == req.AppSlugOrPort |
| 51 | } |
| 52 | |
| 53 | type EncryptedAPIKeyPayload struct { |
| 54 | jwtutils.RegisteredClaims |
no outgoing calls