MCPcopy Create free account
hub / github.com/goadesign/goa / getSecurityAttributes

Function getSecurityAttributes

expr/grpc_endpoint.go:530–563  ·  view source on GitHub ↗

getSecurityAttributes returns the attributes that describes a security scheme from a method expression.

(m *MethodExpr)

Source from the content-addressed store, hash-verified

528// getSecurityAttributes returns the attributes that describes a security
529// scheme from a method expression.
530func getSecurityAttributes(m *MethodExpr) []string {
531 var secAttrs []string
532
533 for _, req := range m.Requirements {
534 for _, sch := range req.Schemes {
535 switch sch.Kind {
536 case BasicAuthKind:
537 if field := TaggedAttribute(m.Payload, "security:username"); field != "" {
538 secAttrs = append(secAttrs, field)
539 }
540 if field := TaggedAttribute(m.Payload, "security:password"); field != "" {
541 secAttrs = append(secAttrs, field)
542 }
543 case APIKeyKind:
544 if field := TaggedAttribute(m.Payload, "security:apikey:"+sch.SchemeName); field != "" {
545 secAttrs = append(secAttrs, field)
546 }
547 case BearerKind:
548 if field := TaggedAttribute(m.Payload, "security:bearer"); field != "" {
549 secAttrs = append(secAttrs, field)
550 }
551 case JWTKind:
552 if field := TaggedAttribute(m.Payload, "security:token"); field != "" {
553 secAttrs = append(secAttrs, field)
554 }
555 case OAuth2Kind:
556 if field := TaggedAttribute(m.Payload, "security:accesstoken"); field != "" {
557 secAttrs = append(secAttrs, field)
558 }
559 }
560 }
561 }
562 return secAttrs
563}

Callers 1

ValidateMethod · 0.85

Calls 1

TaggedAttributeFunction · 0.85

Tested by

no test coverage detected