Skip to content

Commit

Permalink
revert some renames
Browse files Browse the repository at this point in the history
  • Loading branch information
hperl committed Jan 31, 2025
1 parent 01dbaf3 commit 46383a7
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions selfservice/strategy/oidc/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,22 +402,22 @@ func (s *Strategy) HandleCallback(w http.ResponseWriter, r *http.Request, ps htt
req, state, cntnr, err := s.ValidateCallback(w, r, ps)
if err != nil {
if req != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 405 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L405

Added line #L405 was not covered by tests
} else {
s.d.SelfServiceErrorManager().Forward(ctx, w, r, s.HandleError(ctx, w, r, nil, "", nil, err))
}
return
}

if authenticated, err := s.alreadyAuthenticated(ctx, w, r, req); err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 413 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L413

Added line #L413 was not covered by tests
} else if authenticated {
return
}

provider, err := s.Provider(ctx, state.ProviderId)
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 420 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L420

Added line #L420 was not covered by tests
return
}

Expand All @@ -427,37 +427,37 @@ func (s *Strategy) HandleCallback(w http.ResponseWriter, r *http.Request, ps htt
case OAuth2Provider:
token, err := s.exchangeCode(ctx, p, code, PKCEVerifier(state))
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
return
}

et, err = s.encryptOAuth2Tokens(ctx, token)
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 436 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L436

Added line #L436 was not covered by tests
return
}

claims, err = p.Claims(ctx, token, r.URL.Query())
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
return
}
case OAuth1Provider:
token, err := p.ExchangeToken(ctx, r)
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 448 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L448

Added line #L448 was not covered by tests
return
}

claims, err = p.Claims(ctx, token)
if err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 454 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L454

Added line #L454 was not covered by tests
return
}
}

if err = claims.Validate(); err != nil {
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, err))

Check warning on line 460 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L460

Added line #L460 was not covered by tests
return
}

Expand All @@ -472,38 +472,38 @@ func (s *Strategy) HandleCallback(w http.ResponseWriter, r *http.Request, ps htt
return
}
if ff != nil {
s.ForwardError(ctx, w, r, ff, err)
s.forwardError(ctx, w, r, ff, err)
return
}
s.ForwardError(ctx, w, r, a, err)
s.forwardError(ctx, w, r, a, err)
}
return
case *registration.Flow:
a.Active = s.ID()
a.TransientPayload = cntnr.TransientPayload
if ff, err := s.processRegistration(ctx, w, r, a, et, claims, provider, cntnr); err != nil {
if ff != nil {
s.ForwardError(ctx, w, r, ff, err)
s.forwardError(ctx, w, r, ff, err)
return
}
s.ForwardError(ctx, w, r, a, err)
s.forwardError(ctx, w, r, a, err)
}
return
case *settings.Flow:
a.Active = sqlxx.NullString(s.ID())
a.TransientPayload = cntnr.TransientPayload
sess, err := s.d.SessionManager().FetchFromRequest(ctx, r)
if err != nil {
s.ForwardError(ctx, w, r, a, s.HandleError(ctx, w, r, a, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, a, s.HandleError(ctx, w, r, a, state.ProviderId, nil, err))

Check warning on line 497 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L497

Added line #L497 was not covered by tests
return
}
if err := s.linkProvider(ctx, w, r, &settings.UpdateContext{Session: sess, Flow: a}, et, claims, provider); err != nil {
s.ForwardError(ctx, w, r, a, s.HandleError(ctx, w, r, a, state.ProviderId, nil, err))
s.forwardError(ctx, w, r, a, s.HandleError(ctx, w, r, a, state.ProviderId, nil, err))
return
}
return
default:
s.ForwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, errors.WithStack(x.PseudoPanic.
s.forwardError(ctx, w, r, req, s.HandleError(ctx, w, r, req, state.ProviderId, nil, errors.WithStack(x.PseudoPanic.

Check warning on line 506 in selfservice/strategy/oidc/strategy.go

View check run for this annotation

Codecov / codecov/patch

selfservice/strategy/oidc/strategy.go#L506

Added line #L506 was not covered by tests
WithDetailf("cause", "Unexpected type in OpenID Connect flow: %T", a))))
return
}
Expand Down Expand Up @@ -565,7 +565,7 @@ func (s *Strategy) Provider(ctx context.Context, id string) (Provider, error) {
}
}

func (s *Strategy) ForwardError(ctx context.Context, w http.ResponseWriter, r *http.Request, f flow.Flow, err error) {
func (s *Strategy) forwardError(ctx context.Context, w http.ResponseWriter, r *http.Request, f flow.Flow, err error) {
switch ff := f.(type) {
case *login.Flow:
s.d.LoginFlowErrorHandler().WriteFlowError(w, r, ff, s.NodeGroup(), err)
Expand Down Expand Up @@ -680,13 +680,13 @@ func (s *Strategy) populateAccountLinkingUI(ctx context.Context, lf *login.Flow,
continue
}

// Skip the Provider that was used to get here (in case they used an OIDC Provider)
// Skip the provider that was used to get here (in case they used an OIDC provider)
pID := gjson.GetBytes(n.Meta.Label.Context, "provider_id").String()
if n.Group == node.OpenIDConnectGroup {
if pID == usedProviderID {
continue
}
// Hide any Provider that is not available for the user
// Hide any provider that is not available for the user
if loginHintsEnabled && !slices.Contains(availableProviders, pID) {
continue
}
Expand All @@ -697,7 +697,7 @@ func (s *Strategy) populateAccountLinkingUI(ctx context.Context, lf *login.Flow,
case text.InfoSelfServiceLogin:
n.Meta.Label = text.NewInfoLoginAndLink()
case text.InfoSelfServiceLoginWith:
p := gjson.GetBytes(n.Meta.Label.Context, "Provider").String()
p := gjson.GetBytes(n.Meta.Label.Context, "provider").String()
n.Meta.Label = text.NewInfoLoginWithAndLink(p)
}

Expand Down Expand Up @@ -780,7 +780,7 @@ func (s *Strategy) ProcessIDToken(r *http.Request, provider Provider, idToken, i

func (s *Strategy) linkCredentials(ctx context.Context, i *identity.Identity, tokens *identity.CredentialsOIDCEncryptedTokens, provider, subject, organization string) (err error) {
ctx, span := s.d.Tracer(ctx).Tracer().Start(ctx, "strategy.oidc.linkCredentials", trace.WithAttributes(
attribute.String("Provider", provider),
attribute.String("provider", provider),
// attribute.String("subject", subject), // PII
attribute.String("organization", organization)))
defer otelx.End(span, &err)
Expand Down

0 comments on commit 46383a7

Please sign in to comment.