Files
upstream-mirror c60cc7ca75
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
2026-09-15 21:19:12 +05:00

102 lines
3.6 KiB
Go

// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package hook
import (
"encoding/json"
"errors"
"net/http"
"github.com/tidwall/gjson"
"github.com/ory/kratos/selfservice/flow/recovery"
"github.com/ory/kratos/selfservice/flow/verification"
"github.com/ory/kratos/ui/node"
"github.com/ory/kratos/identity"
"github.com/ory/kratos/selfservice/flow/login"
"github.com/ory/kratos/selfservice/flow/registration"
"github.com/ory/kratos/selfservice/flow/settings"
"github.com/ory/kratos/session"
)
var (
_ registration.PostHookPrePersistExecutor = new(Error)
_ registration.PostHookPostPersistExecutor = new(Error)
_ registration.PreHookExecutor = new(Error)
_ login.PreHookExecutor = new(Error)
_ login.PostHookExecutor = new(Error)
_ login.PreHookExecutor = new(Error)
_ settings.PostHookPostPersistExecutor = new(Error)
_ settings.PostHookPrePersistExecutor = new(Error)
_ settings.PreHookExecutor = new(Error)
_ verification.PreHookExecutor = new(Error)
_ recovery.PreHookExecutor = new(Error)
)
type Error struct {
Config json.RawMessage
}
func (e Error) err(path string, abort error) error {
switch gjson.GetBytes(e.Config, path).String() {
case "err":
return errors.New("err")
case "abort":
return abort
}
return nil
}
func (e Error) ExecuteSettingsPreHook(w http.ResponseWriter, r *http.Request, _ settings.PreHookExecutorParams) error {
return e.err("ExecuteSettingsPreHook", settings.ErrHookAbortFlow)
}
func (e Error) ExecuteSettingsPrePersistHook(w http.ResponseWriter, r *http.Request, _ settings.PostHookPrePersistExecutorParams) error {
return e.err("ExecuteSettingsPrePersistHook", settings.ErrHookAbortFlow)
}
func (e Error) ExecuteSettingsPostPersistHook(w http.ResponseWriter, r *http.Request, _ settings.PostHookPostPersistExecutorParams) error {
return e.err("ExecuteSettingsPostPersistHook", settings.ErrHookAbortFlow)
}
func (e Error) ExecuteLoginPostHook(w http.ResponseWriter, r *http.Request, g node.UiNodeGroup, a *login.Flow, s *session.Session) error {
return e.err("ExecuteLoginPostHook", login.ErrHookAbortFlow)
}
func (e Error) ExecuteLoginPreHook(w http.ResponseWriter, r *http.Request, a *login.Flow) error {
return e.err("ExecuteLoginPreHook", login.ErrHookAbortFlow)
}
func (e Error) ExecuteRegistrationPreHook(w http.ResponseWriter, r *http.Request, a *registration.Flow) error {
return e.err("ExecuteRegistrationPreHook", registration.ErrHookAbortFlow)
}
func (e Error) ExecutePostRegistrationPostPersistHook(w http.ResponseWriter, r *http.Request, a *registration.Flow, s *session.Session) error {
return e.err("ExecutePostRegistrationPostPersistHook", registration.ErrHookAbortFlow)
}
func (e Error) ExecutePostRegistrationPrePersistHook(w http.ResponseWriter, r *http.Request, a *registration.Flow, i *identity.Identity) error {
return e.err("ExecutePostRegistrationPrePersistHook", registration.ErrHookAbortFlow)
}
func (e Error) ExecuteRecoveryPreHook(w http.ResponseWriter, r *http.Request, a *recovery.Flow) error {
return e.err("ExecuteRecoveryPreHook", recovery.ErrHookAbortFlow)
}
func (e Error) ExecutePostRecoveryHook(w http.ResponseWriter, r *http.Request, a *recovery.Flow, s *session.Session) error {
return e.err("ExecutePostRecoveryHook", recovery.ErrHookAbortFlow)
}
func (e Error) ExecuteVerificationPreHook(w http.ResponseWriter, r *http.Request, a *verification.Flow) error {
return e.err("ExecuteVerificationPreHook", verification.ErrHookAbortFlow)
}
func (e Error) ExecutePostVerificationHook(w http.ResponseWriter, r *http.Request, a *verification.Flow, i *identity.Identity) error {
return e.err("ExecutePostVerificationHook", verification.ErrHookAbortFlow)
}