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

Function BasicAuthSecurity

dsl/security.go:20–44  ·  view source on GitHub ↗

BasicAuthSecurity defines a basic authentication security scheme. BasicAuthSecurity is a top level DSL. BasicAuthSecurity takes a name as first argument and an optional DSL as second argument. Example: var Basic = BasicAuthSecurity("basicauth", func() { Description("Use your own password!"

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

Source from the content-addressed store, hash-verified

18// Description("Use your own password!")
19// })
20func BasicAuthSecurity(name string, fn ...func()) *expr.SchemeExpr {
21 if _, ok := eval.Current().(eval.TopExpr); !ok {
22 eval.IncompatibleDSL()
23 return nil
24 }
25
26 if securitySchemeRedefined(name) {
27 return nil
28 }
29
30 e := &expr.SchemeExpr{
31 Kind: expr.BasicAuthKind,
32 SchemeName: name,
33 }
34
35 if len(fn) != 0 {
36 if !eval.Execute(fn[0], e) {
37 return nil
38 }
39 }
40
41 expr.Root.Schemes = append(expr.Root.Schemes, e)
42
43 return e
44}
45
46// APIKeySecurity defines an API key security scheme where a key must be
47// provided by the client to perform authorization.

Callers 5

openapi_dsls.goFile · 0.85
dsls.goFile · 0.85
TestTooManyArgErrorFunction · 0.85
security_dsls.goFile · 0.85

Calls 4

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

Tested by 1

TestTooManyArgErrorFunction · 0.68