getSecurityAttributes returns the attributes that describes a security scheme from a method expression.
(m *MethodExpr)
| 528 | // getSecurityAttributes returns the attributes that describes a security |
| 529 | // scheme from a method expression. |
| 530 | func 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 | } |
no test coverage detected