(r Role)
| 205 | } |
| 206 | |
| 207 | func (c *Claims) CheckRole(r Role) error { |
| 208 | if r != Downloader && r != Uploader { |
| 209 | return errors.New("invalid role") |
| 210 | } |
| 211 | |
| 212 | if c.Role != r { |
| 213 | return fmt.Errorf("invalid role, got=%s, want=%s", c.Role, r) |
| 214 | } |
| 215 | |
| 216 | return nil |
| 217 | } |
| 218 | |
| 219 | // InfoFromAuth extracts the JWT claims from the context, note that the JWT verification has happened in the middleware |
| 220 | func InfoFromAuth(ctx context.Context) (*Claims, error) { |
no outgoing calls