snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
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

This commit is contained in:
upstream-mirror
2026-09-15 21:19:12 +05:00
commit c60cc7ca75
8092 changed files with 394160 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0
package code
import (
"context"
"database/sql"
"time"
"github.com/pkg/errors"
"github.com/gofrs/uuid"
"github.com/ory/kratos/identity"
"github.com/ory/x/clock"
"github.com/ory/x/region"
)
// swagger:ignore
type LoginCode struct {
// ID represents the tokens's unique ID.
//
// required: true
// type: string
// format: uuid
ID uuid.UUID `json:"id" db:"id" faker:"-"`
// Address represents the address that the code was sent to.
// this can be an email address or a phone number.
Address string `json:"-" db:"address"`
// AddressType represents the type of the address
// this can be an email address or a phone number.
AddressType identity.CodeChannel `json:"-" db:"address_type"`
// CodeHMAC represents the HMACed value of the verification code
CodeHMAC string `json:"-" db:"code"`
// UsedAt is the timestamp of when the code was used or null if it wasn't yet
UsedAt sql.NullTime `json:"-" db:"used_at"`
// ExpiresAt is the time (UTC) when the token expires.
// required: true
ExpiresAt time.Time `json:"expires_at" faker:"time_type" db:"expires_at"`
// IssuedAt is the time (UTC) when the token was issued.
// required: true
IssuedAt time.Time `json:"issued_at" faker:"time_type" db:"issued_at"`
// CreatedAt is a helper struct field for gobuffalo.pop.
CreatedAt time.Time `json:"-" faker:"-" db:"created_at"`
// UpdatedAt is a helper struct field for gobuffalo.pop.
UpdatedAt time.Time `json:"-" faker:"-" db:"updated_at"`
// FlowID is a helper struct field for gobuffalo.pop.
FlowID uuid.UUID `json:"-" faker:"-" db:"selfservice_login_flow_id"`
NID uuid.UUID `json:"-" faker:"-" db:"nid"`
IdentityID uuid.UUID `json:"identity_id" faker:"-" db:"identity_id"`
}
func (LoginCode) TableName(ctx context.Context) string {
return "identity_login_codes"
}
func (c *LoginCode) Validate(clk clock.Clock) error {
if c == nil {
return errors.WithStack(ErrCodeNotFound())
}
return validateOneTimeCode(c.ExpiresAt, c.UsedAt, clk)
}
func (c *LoginCode) GetHMACCode() string {
return c.CodeHMAC
}
func (c *LoginCode) GetID() uuid.UUID {
return c.ID
}
// swagger:ignore
type CreateLoginCodeParams struct {
// Address is the email address or phone number the code should be sent to.
// required: true
Address string
// AddressType is the type of the address (email or phone number).
// required: true
AddressType identity.CodeChannel
// Code represents the recovery code
// required: true
RawCode string
// ExpiresAt is the time (UTC) when the code expires.
// required: true
ExpiresIn time.Duration
// FlowID is a helper struct field for gobuffalo.pop.
// required: true
FlowID uuid.UUID
// IdentityID is the identity that this code is for
// required: true
IdentityID uuid.UUID
// IdentityRegion optionally carries the already-known region of the
// identity the code is for, so persisters can use it without re-reading
// the identity row.
IdentityRegion region.Region `json:"-" db:"-" faker:"-"`
// InsertExtraColumns appends fixed (key, value) columns to the INSERT
// statement (e.g. crdb_region).
InsertExtraColumns []identity.ExtraColumn `json:"-" db:"-" faker:"-"`
}