MCPcopy Create free account
hub / github.com/couchbase/cbft / authenticate

Method authenticate

grpc_auth.go:113–147  ·  view source on GitHub ↗
(r requestParser)

Source from the content-addressed store, hash-verified

111}
112
113func (a *authWrapper) authenticate(r requestParser) (bool, error) {
114 var authType string
115 if a.mgr != nil && a.mgr.Options() != nil {
116 authType = a.mgr.Options()["authType"]
117 }
118
119 if authType == "" {
120 return true, nil
121 }
122
123 if authType != "cbauth" {
124 return false, nil
125 }
126
127 perms, err := preparePerms(a.mgr, r, a.method, a.path)
128 if err != nil {
129 return false, fmt.Errorf("grpc_auth: preparePerms err: %v", err)
130 }
131
132 if len(perms) <= 0 {
133 return true, nil
134 }
135
136 for _, perm := range perms {
137 allowed, err := CBAuthIsAllowed(a.creds, perm)
138 if err != nil {
139 return false, err
140 }
141
142 if !allowed {
143 return false, err
144 }
145 }
146 return true, nil
147}
148
149// rpcRequestParser implements the requestParser interface
150type rpcRequestParser struct {

Callers

nothing calls this directly

Calls 1

preparePermsFunction · 0.85

Tested by

no test coverage detected