MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / NewUserAuth

Function NewUserAuth

internal/auth/auth.go:114–138  ·  view source on GitHub ↗
(cfg *config.OAuthConfig, store *identity.Store, production bool)

Source from the content-addressed store, hash-verified

112</html>`))
113
114func NewUserAuth(cfg *config.OAuthConfig, store *identity.Store, production bool) *UserAuth {
115 // Derive the user auth callback URL from the existing redirect URL.
116 // e.g. "https://e2a.example.com/api/verify/callback" → "https://e2a.example.com/api/auth/callback"
117 callbackURL := cfg.RedirectURL
118 baseURL := ""
119 if u, err := url.Parse(cfg.RedirectURL); err == nil && u.Host != "" {
120 u.Path = "/api/auth/callback"
121 callbackURL = u.String()
122 baseURL = u.Scheme + "://" + u.Host
123 }
124
125 return &UserAuth{
126 oauthConfig: &oauth2.Config{
127 ClientID: cfg.GoogleClientID,
128 ClientSecret: cfg.GoogleClientSecret,
129 RedirectURL: callbackURL,
130 Scopes: []string{"openid", "email", "profile"},
131 Endpoint: google.Endpoint,
132 },
133 store: store,
134 secure: production,
135 baseURL: baseURL,
136 userInfoURL: defaultUserInfoURL,
137 }
138}
139
140// NewUserAuthWithOAuthConfig creates a UserAuth with a custom oauth2.Config and
141// userinfo URL. This is intended for testing against fake OAuth servers.

Callers 4

setupUserAuthFunction · 0.92
newConsentFixtureFunction · 0.92
setupAPIWithLimitsFunction · 0.92
mainFunction · 0.92

Calls 1

StringMethod · 0.45

Tested by 3

setupUserAuthFunction · 0.74
newConsentFixtureFunction · 0.74
setupAPIWithLimitsFunction · 0.74