(ctx context.Context, r *http.Request)
| 1287 | } |
| 1288 | |
| 1289 | func (a *accessAdapter) Authenticate(ctx context.Context, r *http.Request) (result *sdkaccess.Result, authErr *sdkaccess.AuthError) { |
| 1290 | if a == nil || a.provider == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) { |
| 1291 | return nil, sdkaccess.NewNotHandledError() |
| 1292 | } |
| 1293 | defer func() { |
| 1294 | if recovered := recover(); recovered != nil { |
| 1295 | a.host.fusePlugin(a.pluginID, "FrontendAuthProvider.Authenticate", recovered) |
| 1296 | result = nil |
| 1297 | authErr = sdkaccess.NewNotHandledError() |
| 1298 | } |
| 1299 | }() |
| 1300 | |
| 1301 | body, errReadAll := readAndRestoreRequestBody(r) |
| 1302 | if errReadAll != nil { |
| 1303 | return nil, sdkaccess.NewInternalAuthError("failed to read plugin auth request body", errReadAll) |
| 1304 | } |
| 1305 | resp, errAuthenticate := a.provider.Authenticate(ctx, pluginapi.FrontendAuthRequest{ |
| 1306 | Method: r.Method, |
| 1307 | Path: r.URL.Path, |
| 1308 | Headers: cloneHeader(r.Header), |
| 1309 | Query: cloneValues(r.URL.Query()), |
| 1310 | Body: bytes.Clone(body), |
| 1311 | }) |
| 1312 | if errAuthenticate != nil || !resp.Authenticated { |
| 1313 | return nil, sdkaccess.NewNotHandledError() |
| 1314 | } |
| 1315 | providerID := a.Identifier() |
| 1316 | if providerID == "" { |
| 1317 | return nil, sdkaccess.NewNotHandledError() |
| 1318 | } |
| 1319 | return &sdkaccess.Result{ |
| 1320 | Provider: providerID, |
| 1321 | Principal: resp.Principal, |
| 1322 | Metadata: cloneStringMap(resp.Metadata), |
| 1323 | }, nil |
| 1324 | } |
| 1325 | |
| 1326 | type executorAdapter struct { |
| 1327 | host *Host |
nothing calls this directly
no test coverage detected