MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / CheckRole

Method CheckRole

internal/robotaccount/cas/robotaccount.go:207–217  ·  view source on GitHub ↗
(r Role)

Source from the content-addressed store, hash-verified

205}
206
207func (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
220func InfoFromAuth(ctx context.Context) (*Claims, error) {

Callers 4

TestCheckRoleFunction · 0.95
ServeHTTPMethod · 0.80
WriteMethod · 0.80
ReadMethod · 0.80

Calls

no outgoing calls

Tested by 1

TestCheckRoleFunction · 0.76