MCPcopy Index your code
hub / github.com/supabase/auth / loadFlowState

Method loadFlowState

internal/api/external_oauth.go:31–58  ·  view source on GitHub ↗

loadFlowState parses the `state` query parameter as a UUID, loads the flow state from the database, and extracts the provider requested

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

29// loadFlowState parses the `state` query parameter as a UUID,
30// loads the flow state from the database, and extracts the provider requested
31func (a *API) loadFlowState(w http.ResponseWriter, r *http.Request) (context.Context, error) {
32 ctx := r.Context()
33 db := a.db.WithContext(ctx)
34
35 oauthToken := r.URL.Query().Get("oauth_token")
36 if oauthToken != "" {
37 ctx = withRequestToken(ctx, oauthToken)
38 }
39 oauthVerifier := r.URL.Query().Get("oauth_verifier")
40 if oauthVerifier != "" {
41 ctx = withOAuthVerifier(ctx, oauthVerifier)
42 }
43
44 var err error
45 ctx, err = a.loadExternalState(ctx, r, db)
46 if err != nil {
47 u, uerr := url.ParseRequestURI(a.config.SiteURL)
48 if uerr != nil {
49 return ctx, apierrors.NewInternalServerError("site url is improperly formatted").WithInternalError(uerr)
50 }
51
52 q := getErrorQueryString(err, utilities.GetRequestID(ctx), observability.GetLogEntry(r).Entry, u.Query())
53 u.RawQuery = q.Encode()
54
55 http.Redirect(w, r, u.String(), http.StatusSeeOther)
56 }
57 return ctx, err
58}
59
60func (a *API) oAuthCallback(ctx context.Context, r *http.Request, providerType string) (*OAuthProviderData, error) {
61 db := a.db.WithContext(ctx)

Callers

nothing calls this directly

Calls 12

loadExternalStateMethod · 0.95
NewInternalServerErrorFunction · 0.92
GetRequestIDFunction · 0.92
GetLogEntryFunction · 0.92
withRequestTokenFunction · 0.85
withOAuthVerifierFunction · 0.85
getErrorQueryStringFunction · 0.85
WithContextMethod · 0.80
EncodeMethod · 0.80
GetMethod · 0.45
WithInternalErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected