userexport

package
v0.0.0-...-09efcc3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const BatchSize = 1000
View Source
const PresignGetExpiresForUserExport time.Duration = 1 * duration.PerMinute

PresignGetExpiresForUserExport is how long the presign GET request remains valid for user export.

Variables

View Source
var ErrUserExportDisabled = apierrors.InternalError.WithReason("UserExportDisabled").New("User export disabled")
View Source
var ErrUserExportDuplicateField = apierrors.Invalid.WithReason("UserExportNonUniqueFieldNames")

Functions

func ExtractCSVHeaderField

func ExtractCSVHeaderField(fieldPointer []*FieldPointer) (headerFields []string, err error)

func TraverseRecordValue

func TraverseRecordValue(jsonMap interface{}, pointer string) (fieldValue string, err error)

Types

type Address

type Address struct {
	Formatted     string `json:"formatted,omitempty"`
	StreetAddress string `json:"street_address,omitempty"`
	Locality      string `json:"locality,omitempty"`
	Region        string `json:"region,omitempty"`
	PostalCode    string `json:"postal_code,omitempty"`
	Country       string `json:"country,omitempty"`
}

type CSVField

type CSVField struct {
	Fields []*FieldPointer `json:"fields,omitempty"`
}

type FieldPointer

type FieldPointer struct {
	Pointer   string `json:"pointer,omitempty"`
	FieldName string `json:"field_name,omitempty"`
}

type HTTPClient

type HTTPClient struct {
	*http.Client
}

func NewHTTPClient

func NewHTTPClient() HTTPClient

type Identity

type Identity struct {
	Type    model.IdentityType     `json:"type"`
	LoginID *IdentityLoginID       `json:"login_id,omitempty"`
	OAuth   *IdentityOAuth         `json:"oauth,omitempty"`
	LDAP    *IdentityLDAP          `json:"ldap,omitempty"`
	Claims  map[string]interface{} `json:"claims,omitempty"`
}

type IdentityLDAP

type IdentityLDAP struct {
	ServerName           string                 `json:"server_name,omitempty"`
	LastLoginUsername    string                 `json:"last_login_username,omitempty"`
	UserIDAttributeName  string                 `json:"user_id_attribute_name,omitempty"`
	UserIDAttributeValue string                 `json:"user_id_attribute_value,omitempty"`
	Attributes           map[string]interface{} `json:"attributes,omitempty"`
}

type IdentityLoginID

type IdentityLoginID struct {
	Key           string `json:"key,omitempty"`
	Type          string `json:"type,omitempty"`
	Value         string `json:"value,omitempty"`
	OriginalValue string `json:"original_value,omitempty"`
}

type IdentityOAuth

type IdentityOAuth struct {
	ProviderAlias     string                 `json:"provider_alias,omitempty"`
	ProviderType      string                 `json:"provider_type,omitempty"`
	ProviderSubjectID string                 `json:"provider_subject_id,omitempty"`
	UserProfile       map[string]interface{} `json:"user_profile,omitempty"`
}

type Logger

type Logger struct{ *log.Logger }

func NewLogger

func NewLogger(lf *log.Factory) Logger

type MFA

type MFA struct {
	Emails       []string   `json:"emails,omitempty"`
	PhoneNumbers []string   `json:"phone_numbers,omitempty"`
	TOTPs        []*MFATOTP `json:"totps,omitempty"`
}

type MFATOTP

type MFATOTP struct {
	Secret string `json:"secret,omitempty"`
	URI    string `json:"uri,omitempty"`
}

type Record

type Record struct {
	Sub string `json:"sub,omitempty"`

	PreferredUsername string `json:"preferred_username,omitempty"`
	Email             string `json:"email,omitempty"`
	PhoneNumber       string `json:"phone_number,omitempty"`

	EmailVerified       bool `json:"email_verified"`
	PhoneNumberVerified bool `json:"phone_number_verified"`

	Name       string   `json:"name,omitempty"`
	GivenName  string   `json:"given_name,omitempty"`
	FamilyName string   `json:"family_name,omitempty"`
	MiddleName string   `json:"middle_name,omitempty"`
	Nickname   string   `json:"nickname,omitempty"`
	Profile    string   `json:"profile,omitempty"`
	Picture    string   `json:"picture,omitempty"`
	Website    string   `json:"website,omitempty"`
	Gender     string   `json:"gender,omitempty"`
	Birthdate  string   `json:"birthdate,omitempty"`
	Zoneinfo   string   `json:"zoneinfo,omitempty"`
	Locale     string   `json:"locale,omitempty"`
	Address    *Address `json:"address,omitempty"`

	CustomAttributes map[string]interface{} `json:"custom_attributes,omitempty"`

	Roles  []string `json:"roles,omitempty"`
	Groups []string `json:"groups,omitempty"`

	Disabled bool       `json:"disabled"`
	DeleteAt *time.Time `json:"delete_at,omitempty"`

	Identities []*Identity `json:"identities,omitempty"`

	Mfa *MFA `json:"mfa,omitempty"`

	BiometricCount int `json:"biometric_count"`
	PasskeyCount   int `json:"passkey_count"`
}

type Request

type Request struct {
	Format string    `json:"format,omitempty"`
	CSV    *CSVField `json:"csv,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"`
	FailedAt    *time.Time            `json:"failed_at,omitempty"`
	Status      redisqueue.TaskStatus `json:"status,omitempty"`
	Request     *Request              `json:"request,omitempty"`
	DownloadUrl string                `json:"download_url,omitempty"`
	Error       *apierrors.APIError   `json:"error,omitempty"`
}

func NewResponseFromTask

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

type Result

type Result struct {
	Filename string              `json:"file_name,omitempty"`
	Error    *apierrors.APIError `json:"error,omitempty"`
}

type UserExportCloudStorage

type UserExportCloudStorage interface {
	PresignPutObject(ctx context.Context, name string, header http.Header) (*http.Request, error)
	PresignGetObject(ctx context.Context, name string, expire time.Duration) (*url.URL, error)
}

func NewCloudStorage

func NewCloudStorage(objectStoreConfig *config.UserExportObjectStoreConfig, c clock.Clock) UserExportCloudStorage

type UserExportService

type UserExportService struct {
	AppDatabase  *appdb.Handle
	Config       *config.UserProfileConfig
	UserQueries  UserQueries
	Logger       Logger
	HTTPOrigin   httputil.HTTPOrigin
	HTTPClient   HTTPClient
	CloudStorage UserExportCloudStorage
	Clock        clock.Clock
}

func (*UserExportService) ExportRecords

func (s *UserExportService) ExportRecords(ctx context.Context, request *Request, task *redisqueue.Task) (outputFilename string, err error)

func (*UserExportService) ExportToCSV

func (s *UserExportService) ExportToCSV(ctx context.Context, tmpResult *os.File, request *Request, task *redisqueue.Task) (err error)

func (*UserExportService) ExportToNDJson

func (s *UserExportService) ExportToNDJson(ctx context.Context, tmpResult *os.File, request *Request, task *redisqueue.Task) (err error)

func (*UserExportService) ParseExportRequest

func (s *UserExportService) ParseExportRequest(w http.ResponseWriter, r *http.Request) (*Request, error)

func (*UserExportService) UploadResult

func (s *UserExportService) UploadResult(ctx context.Context, key string, resultFile *os.File, format string) (response *http.Response, err error)

type UserQueries

type UserQueries interface {
	GetPageForExport(ctx context.Context, page uint64, limit uint64) (users []*user.UserForExport, err error)
	CountAll(ctx context.Context) (count uint64, err error)
}

Jump to

Keyboard shortcuts

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