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

Function APIKeySecurity

dsl/security.go:59–83  ·  view source on GitHub ↗

APIKeySecurity defines an API key security scheme where a key must be provided by the client to perform authorization. APIKeySecurity is a top level DSL. APIKeySecurity takes a name as first argument and an optional DSL as second argument. Example: var APIKey = APIKeySecurity("key", func() {

(name string, fn ...func())

Source from the content-addressed store, hash-verified

57// Description("Shared secret")
58// })
59func APIKeySecurity(name string, fn ...func()) *expr.SchemeExpr {
60 if _, ok := eval.Current().(eval.TopExpr); !ok {
61 eval.IncompatibleDSL()
62 return nil
63 }
64
65 if securitySchemeRedefined(name) {
66 return nil
67 }
68
69 e := &expr.SchemeExpr{
70 Kind: expr.APIKeyKind,
71 SchemeName: name,
72 }
73
74 if len(fn) != 0 {
75 if !eval.Execute(fn[0], e) {
76 return nil
77 }
78 }
79
80 expr.Root.Schemes = append(expr.Root.Schemes, e)
81
82 return e
83}
84
85// OAuth2Security defines an OAuth2 security scheme. The DSL provided as second
86// argument defines the specific flows supported by the scheme. The supported

Callers 6

openapi_dsls.goFile · 0.85
dsls.goFile · 0.85
security_dsls.goFile · 0.85
service_dsls.goFile · 0.85

Calls 4

CurrentFunction · 0.92
IncompatibleDSLFunction · 0.92
ExecuteFunction · 0.92
securitySchemeRedefinedFunction · 0.85

Tested by

no test coverage detected