userimport

package
v0.0.0-...-ee57881 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 35 Imported by: 1

Documentation

Index

Constants

View Source
const (
	IdentifierEmail             = "email"
	IdentifierPreferredUsername = "preferred_username"
	IdentifierPhoneNumber       = "phone_number"
)
View Source
const JobTTL = 24 * time.Hour
View Source
const (
	PasswordTypeBcrypt = "bcrypt"
)
View Source
const RedactPlaceholder = "REDACTED"

Variables

View Source
var BodyMaxSize int64 = 500 * 1000

BodyMaxSize is 500KB.

View Source
var RecordSchemaForIdentifierEmail *validation.SimpleSchema
View Source
var RecordSchemaForIdentifierPhoneNumber *validation.SimpleSchema
View Source
var RecordSchemaForIdentifierPreferredUsername *validation.SimpleSchema
View Source
var RequestSchema = validation.NewSimpleSchema(`
{
	"type": "object",
	"additionalProperties": false,
	"properties": {
		"upsert": {
			"type": "boolean"
		},
		"identifier": {
			"type": "string",
			"enum": ["preferred_username", "email", "phone_number"]
		},
		"records": {
			"type": "array",
			"minItems": 1,
			"items": {
				"type": "object"
			}
		}
	},
	"required": ["identifier", "records"]
}
`)

Functions

This section is empty.

Types

type AuthenticatorService

type AuthenticatorService interface {
	New(ctx context.Context, spec *authenticator.Spec) (*authenticator.Info, error)
	Create(ctx context.Context, info *authenticator.Info, markVerified bool) error
	List(ctx context.Context, userID string, filters ...authenticator.Filter) ([]*authenticator.Info, error)
	Delete(ctx context.Context, info *authenticator.Info) error
}

type CustomAttributesService

type CustomAttributesService interface {
	UpdateCustomAttributesWithList(ctx context.Context, role accesscontrol.Role, userID string, l attrs.List) error
}

type Detail

type Detail struct {
	Index    int                   `json:"index"`
	Record   Record                `json:"record,omitempty"`
	Outcome  Outcome               `json:"outcome,omitempty"`
	UserID   string                `json:"user_id,omitempty"`
	Warnings []Warning             `json:"warnings,omitempty"`
	Errors   []*apierrors.APIError `json:"errors,omitempty"`
}

type IdentityService

type IdentityService interface {
	New(ctx context.Context, userID string, spec *identity.Spec, options identity.NewIdentityOptions) (*identity.Info, error)
	UpdateWithSpec(ctx context.Context, info *identity.Info, spec *identity.Spec, options identity.NewIdentityOptions) (*identity.Info, error)

	Create(ctx context.Context, info *identity.Info) error
	Delete(ctx context.Context, info *identity.Info) error
	Update(ctx context.Context, oldInfo *identity.Info, newInfo *identity.Info) error
	CheckDuplicated(ctx context.Context, info *identity.Info) (dup *identity.Info, err error)
	ListByClaim(ctx context.Context, name string, value string) ([]*identity.Info, error)
	ListByUser(ctx context.Context, userID string) ([]*identity.Info, error)
}

type Job

type Job struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	TaskIDs   []string  `json:"task_ids"`
}

type JobManager

type JobManager struct {
	AppID config.AppID
	Clock clock.Clock

	AdminAPIFeatureConfig *config.AdminAPIFeatureConfig
	TaskProducer          TaskProducer
	UsageLimiter          UsageLimiter
	Store                 Store
}

func (*JobManager) EnqueueJob

func (m *JobManager) EnqueueJob(ctx context.Context, request *Request) (*Response, error)

func (*JobManager) GetJob

func (m *JobManager) GetJob(ctx context.Context, jobID string) (*Response, error)

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type MFA

type MFA map[string]interface{}

func (MFA) Email

func (m MFA) Email() (*string, bool)

func (MFA) MaybePassword

func (m MFA) MaybePassword() (value map[string]interface{}, exist bool, ok bool)

func (MFA) MaybeTOTP

func (m MFA) MaybeTOTP() (value map[string]interface{}, exist bool, ok bool)

func (MFA) Password

func (m MFA) Password() (map[string]interface{}, bool)

func (MFA) PhoneNumber

func (m MFA) PhoneNumber() (*string, bool)

func (MFA) Redact

func (m MFA) Redact()

func (MFA) TOTP

func (m MFA) TOTP() (map[string]interface{}, bool)

type Options

type Options struct {
	Upsert     bool
	Identifier string
}

func (*Options) RecordSchema

func (o *Options) RecordSchema() *validation.SimpleSchema

type Outcome

type Outcome string
const (
	OutcomeInserted Outcome = "inserted"
	OutcomeUpdated  Outcome = "updated"
	OutcomeSkipped  Outcome = "skipped"
	OutcomeFailed   Outcome = "failed"
)

type Password

type Password map[string]interface{}

func (Password) ExpireAfter

func (m Password) ExpireAfter() *time.Time

func (Password) PasswordHash

func (m Password) PasswordHash() string

func (Password) Redact

func (m Password) Redact()

func (Password) Type

func (m Password) Type() string

type Record

type Record map[string]interface{}

func (Record) CustomAttributesList

func (m Record) CustomAttributesList() (attrsList attrs.List)

func (Record) Disabled

func (m Record) Disabled() (bool, bool)

func (Record) Email

func (m Record) Email() (*string, bool)

func (Record) EmailVerified

func (m Record) EmailVerified() (bool, bool)

func (Record) Groups

func (m Record) Groups() ([]string, bool)

func (Record) MFA

func (m Record) MFA() (map[string]interface{}, bool)

func (Record) MaybeMFA

func (m Record) MaybeMFA() (value map[string]interface{}, exist bool, ok bool)

func (Record) MaybePassword

func (m Record) MaybePassword() (value map[string]interface{}, exist bool, ok bool)

func (Record) NonIdentityAwareStandardAttributesList

func (m Record) NonIdentityAwareStandardAttributesList() (attrsList attrs.List)

func (Record) Password

func (m Record) Password() (map[string]interface{}, bool)

func (Record) PhoneNumber

func (m Record) PhoneNumber() (*string, bool)

func (Record) PhoneNumberVerified

func (m Record) PhoneNumberVerified() (bool, bool)

func (Record) PreferredUsername

func (m Record) PreferredUsername() (*string, bool)

func (Record) Redact

func (m Record) Redact()

func (Record) Roles

func (m Record) Roles() ([]string, bool)

type Request

type Request struct {
	Upsert     bool   `json:"upsert,omitempty"`
	Identifier string `json:"identifier,omitempty"`
	// Records is json.RawMessage because we want to delay the deserialization until we actually process the record.
	Records []json.RawMessage `json:"records,omitempty"`
}

type Response

type Response struct {
	ID          string                `json:"id,omitempty"`
	CreatedAt   *time.Time            `json:"created_at,omitempty"`
	CompletedAt *time.Time            `json:"completed_at,omitempty"`
	Status      redisqueue.TaskStatus `json:"status,omitempty"`
	Error       *apierrors.APIError   `json:"error,omitempty"`
	Summary     *Summary              `json:"summary,omitempty"`
	Details     []Detail              `json:"details,omitempty"`
}

func NewResponseFromJob

func NewResponseFromJob(job *Job) *Response

func NewResponseFromTask

func NewResponseFromTask(task *redisqueue.Task) (*Response, error)

func (*Response) AggregateTaskResult

func (r *Response) AggregateTaskResult(taskOffset int, task *redisqueue.Task) error

type Result

type Result struct {
	Summary *Summary `json:"summary,omitempty"`
	Details []Detail `json:"details,omitempty"`
}

type RolesGroupsCommands

type RolesGroupsCommands interface {
	ResetUserGroup(ctx context.Context, options *rolesgroups.ResetUserGroupOptions) error
	ResetUserRole(ctx context.Context, options *rolesgroups.ResetUserRoleOptions) error
}

type SearchReindexService

type SearchReindexService interface {
	MarkUsersAsReindexRequiredInTx(ctx context.Context, userIDs []string) error
	EnqueueReindexUserTask(ctx context.Context, userID string) error
}

type StandardAttributesService

type StandardAttributesService interface {
	UpdateStandardAttributes(ctx context.Context, role accesscontrol.Role, userID string, stdAttrs map[string]interface{}) error
}

type Store

type Store interface {
	CreateJob(ctx context.Context, job *Job) error
	GetJob(ctx context.Context, jobID string) (*Job, error)
}

type StoreRedis

type StoreRedis struct {
	AppID config.AppID
	Redis *appredis.Handle
}

func (*StoreRedis) CreateJob

func (s *StoreRedis) CreateJob(ctx context.Context, job *Job) error

func (*StoreRedis) GetJob

func (s *StoreRedis) GetJob(ctx context.Context, jobID string) (*Job, error)

type Summary

type Summary struct {
	Total    int `json:"total"`
	Inserted int `json:"inserted"`
	Updated  int `json:"updated"`
	Skipped  int `json:"skipped"`
	Failed   int `json:"failed"`
}

type TOTP

type TOTP map[string]interface{}

func (TOTP) Redact

func (m TOTP) Redact()

func (TOTP) Secret

func (m TOTP) Secret() string

type TaskProducer

type TaskProducer interface {
	NewTask(appID string, input json.RawMessage, taskIDPrefix string) *redisqueue.Task
	EnqueueTask(ctx context.Context, task *redisqueue.Task) error
	GetTask(ctx context.Context, item *redisqueue.QueueItem) (*redisqueue.Task, error)
}

type UsageLimiter

type UsageLimiter interface {
	ReserveN(ctx context.Context, name usage.LimitName, n int, config *config.UsageLimitConfig) (*usage.Reservation, error)
}

type UserCommands

type UserCommands interface {
	Create(ctx context.Context, userID string) (*user.User, error)
	UpdateAccountStatus(ctx context.Context, userID string, accountStatus user.AccountStatus) error
}

type UserImportService

type UserImportService struct {
	AppDatabase          *appdb.Handle
	LoginIDConfig        *config.LoginIDConfig
	Identities           IdentityService
	Authenticators       AuthenticatorService
	UserCommands         UserCommands
	UserQueries          UserQueries
	VerifiedClaims       VerifiedClaimService
	StandardAttributes   StandardAttributesService
	CustomAttributes     CustomAttributesService
	RolesGroupsCommands  RolesGroupsCommands
	SearchReindexService SearchReindexService
	Logger               Logger
}

func (*UserImportService) ImportRecords

func (s *UserImportService) ImportRecords(ctx context.Context, request *Request) *Result

type UserQueries

type UserQueries interface {
	GetRaw(ctx context.Context, userID string) (*user.User, error)
}

type VerifiedClaimService

type VerifiedClaimService interface {
	NewVerifiedClaim(ctx context.Context, userID string, claimName string, claimValue string) *verification.Claim

	MarkClaimVerified(ctx context.Context, claim *verification.Claim) error
	GetClaims(ctx context.Context, userID string) ([]*verification.Claim, error)
	DeleteClaim(ctx context.Context, claim *verification.Claim) error
}

type Warning

type Warning struct {
	Message string `json:"message,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL