(r requestParser)
| 111 | } |
| 112 | |
| 113 | func (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 |
| 150 | type rpcRequestParser struct { |
nothing calls this directly
no test coverage detected