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

Method Authenticate

sdk/access/manager.go:45–88  ·  view source on GitHub ↗

Authenticate evaluates providers until one succeeds.

(ctx context.Context, r *http.Request)

Source from the content-addressed store, hash-verified

43
44// Authenticate evaluates providers until one succeeds.
45func (m *Manager) Authenticate(ctx context.Context, r *http.Request) (*Result, *AuthError) {
46 if m == nil {
47 return nil, nil
48 }
49 providers := m.Providers()
50 if len(providers) == 0 {
51 return nil, nil
52 }
53
54 var (
55 missing bool
56 invalid bool
57 )
58
59 for _, provider := range providers {
60 if provider == nil {
61 continue
62 }
63 res, authErr := provider.Authenticate(ctx, r)
64 if authErr == nil {
65 return res, nil
66 }
67 if IsAuthErrorCode(authErr, AuthErrorCodeNotHandled) {
68 continue
69 }
70 if IsAuthErrorCode(authErr, AuthErrorCodeNoCredentials) {
71 missing = true
72 continue
73 }
74 if IsAuthErrorCode(authErr, AuthErrorCodeInvalidCredential) {
75 invalid = true
76 continue
77 }
78 return nil, authErr
79 }
80
81 if invalid {
82 return nil, NewInvalidCredentialError()
83 }
84 if missing {
85 return nil, NewNoCredentialsError()
86 }
87 return nil, NewNoCredentialsError()
88}

Callers

nothing calls this directly

Calls 5

ProvidersMethod · 0.95
IsAuthErrorCodeFunction · 0.85
NewNoCredentialsErrorFunction · 0.85
AuthenticateMethod · 0.65

Tested by

no test coverage detected