MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / Authenticate

Method Authenticate

internal/pluginhost/adapters.go:1289–1324  ·  view source on GitHub ↗
(ctx context.Context, r *http.Request)

Source from the content-addressed store, hash-verified

1287}
1288
1289func (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
1326type executorAdapter struct {
1327 host *Host

Callers

nothing calls this directly

Calls 11

IdentifierMethod · 0.95
cloneStringMapFunction · 0.85
isPluginFusedMethod · 0.80
pluginIdentityCurrentMethod · 0.80
fusePluginMethod · 0.80
QueryMethod · 0.80
cloneHeaderFunction · 0.70
cloneValuesFunction · 0.70
AuthenticateMethod · 0.65
CloneMethod · 0.45

Tested by

no test coverage detected