Fix indentation after errors.AsType refactor
Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -1114,9 +1114,9 @@ func (impl *Implm) runTrustCenterServer(
|
|||||||
cert, err := certSelector.GetCertificate(hello)
|
cert, err := certSelector.GetCertificate(hello)
|
||||||
// Silently reject connections without SNI (load balancers, health checks, scanners)
|
// Silently reject connections without SNI (load balancers, health checks, scanners)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errors.AsType[*certmanager.NoSNIError](err); ok {
|
if _, ok := errors.AsType[*certmanager.NoSNIError](err); ok {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -62,31 +62,31 @@ func NewAPIKeyMiddleware(svc *iam.Service, tokenSecret string) func(next http.Ha
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiKey, err := svc.APIKeyService.GetAPIKey(ctx, keyID)
|
apiKey, err := svc.APIKeyService.GetAPIKey(ctx, keyID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errors.AsType[*iam.ErrPersonalAPIKeyNotFound](err); ok {
|
if _, ok := errors.AsType[*iam.ErrPersonalAPIKeyNotFound](err); ok {
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := errors.AsType[*iam.ErrPersonalAPIKeyExpired](err); ok {
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Errorf("cannot get personal API key: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := errors.AsType[*iam.ErrPersonalAPIKeyExpired](err); ok {
|
identity, err := svc.AccountService.GetIdentity(ctx, apiKey.IdentityID)
|
||||||
next.ServeHTTP(w, r)
|
if err != nil {
|
||||||
return
|
if _, ok := errors.AsType[*iam.ErrIdentityNotFound](err); ok {
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Errorf("cannot get identity: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get personal API key: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
identity, err := svc.AccountService.GetIdentity(ctx, apiKey.IdentityID)
|
|
||||||
if err != nil {
|
|
||||||
if _, ok := errors.AsType[*iam.ErrIdentityNotFound](err); ok {
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get identity: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx = ContextWithAPIKey(ctx, apiKey)
|
ctx = ContextWithAPIKey(ctx, apiKey)
|
||||||
ctx = ContextWithIdentity(ctx, identity)
|
ctx = ContextWithIdentity(ctx, identity)
|
||||||
|
|
||||||
|
|||||||
@@ -65,37 +65,37 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session, err := svc.SessionService.GetSession(ctx, sessionID)
|
session, err := svc.SessionService.GetSession(ctx, sessionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errors.AsType[*iam.ErrSessionNotFound](err); ok {
|
if _, ok := errors.AsType[*iam.ErrSessionNotFound](err); ok {
|
||||||
securecookie.Clear(w, cookieConfig)
|
securecookie.Clear(w, cookieConfig)
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := errors.AsType[*iam.ErrSessionExpired](err); ok {
|
||||||
|
securecookie.Clear(w, cookieConfig)
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Errorf("cannot get session: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := errors.AsType[*iam.ErrSessionExpired](err); ok {
|
identity, err := svc.AccountService.GetIdentity(ctx, session.IdentityID)
|
||||||
securecookie.Clear(w, cookieConfig)
|
if err != nil {
|
||||||
next.ServeHTTP(w, r)
|
if _, ok := errors.AsType[*iam.ErrIdentityNotFound](err); ok {
|
||||||
|
securecookie.Clear(w, cookieConfig)
|
||||||
|
next.ServeHTTP(w, r)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
panic(fmt.Errorf("cannot get identity: %w", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get session: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
identity, err := svc.AccountService.GetIdentity(ctx, session.IdentityID)
|
|
||||||
if err != nil {
|
|
||||||
if _, ok := errors.AsType[*iam.ErrIdentityNotFound](err); ok {
|
|
||||||
securecookie.Clear(w, cookieConfig)
|
|
||||||
next.ServeHTTP(w, r)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
panic(fmt.Errorf("cannot get identity: %w", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
userAgent := r.UserAgent()
|
userAgent := r.UserAgent()
|
||||||
// TODO: will work well when no layer 7 proxy is in front of the server
|
// TODO: will work well when no layer 7 proxy is in front of the server
|
||||||
var ipAddress net.IP
|
var ipAddress net.IP
|
||||||
|
|||||||
@@ -79,13 +79,13 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
|
|||||||
|
|
||||||
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
|
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errors.AsType[*iam.ErrExpiredToken](err); ok {
|
if _, ok := errors.AsType[*iam.ErrExpiredToken](err); ok {
|
||||||
return nil, gqlutils.Invalid(ctx, err)
|
return nil, gqlutils.Invalid(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := errors.AsType[*iam.ErrInvalidToken](err); ok {
|
if _, ok := errors.AsType[*iam.ErrInvalidToken](err); ok {
|
||||||
return nil, gqlutils.Invalid(ctx, err)
|
return nil, gqlutils.Invalid(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
|
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
|
||||||
|
|
||||||
@@ -101,13 +101,13 @@ func (r *mutationResolver) VerifyMagicLink(ctx context.Context, input types.Veri
|
|||||||
|
|
||||||
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
|
identity, session, continueURL, err = r.iam.AuthService.OpenSessionWithMagicLink(ctx, input.Token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if _, ok := errors.AsType[*iam.ErrExpiredToken](err); ok {
|
if _, ok := errors.AsType[*iam.ErrExpiredToken](err); ok {
|
||||||
return nil, gqlutils.Invalid(ctx, err)
|
return nil, gqlutils.Invalid(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := errors.AsType[*iam.ErrInvalidToken](err); ok {
|
if _, ok := errors.AsType[*iam.ErrInvalidToken](err); ok {
|
||||||
return nil, gqlutils.Invalid(ctx, err)
|
return nil, gqlutils.Invalid(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
|
r.logger.ErrorCtx(ctx, "cannot open session with magic link", log.Error(err))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user