lib/api/members/members_models/clerk_user.go

271 lines
11 KiB
Go
Raw Permalink Normal View History

2023-04-11 14:59:35 +00:00
// Code generated by go-swagger; DO NOT EDIT.
// (c) 2012-2020 by Taxnexus, Inc.
// All rights reserved worldwide.
// Proprietary product; unlicensed use is not allowed
package members_models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ClerkUser Clerk user object
//
// swagger:model ClerkUser
type ClerkUser struct {
// If Backup Codes are configured on the instance, you can provide them to enable it on the newly created user without the need to reset them.
// You must provide the backup codes in plain format or the corresponding bcrypt digest.
BackupCodes []string `json:"backup_codes"`
// A custom date/time denoting _when_ the user signed up to the application, specified in RFC3339 format (e.g. `2012-10-20T07:15:20.902Z`).
CreatedAt string `json:"created_at,omitempty"`
// Email addresses to add to the user.
// Must be unique across your instance.
// The first email address will be set as the user's primary email address.
EmailAddress []string `json:"email_address"`
// The ID of the user as used in your external systems or your previous authentication solution.
// Must be unique across your instance.
ExternalID string `json:"external_id,omitempty"`
// The first name to assign to the user
FirstName string `json:"first_name,omitempty"`
// The last name to assign to the user
LastName string `json:"last_name,omitempty"`
// The plaintext password to give the user.
// Must be at least 8 characters long, and can not be in any list of hacked passwords.
Password string `json:"password,omitempty"`
// In case you already have the password digests and not the passwords, you can use them for the newly created user via this property.
// The digests should be generated with one of the supported algorithms.
// The hashing algorithm can be specified using the `password_hasher` property.
PasswordDigest string `json:"password_digest,omitempty"`
// The hashing algorithm that was used to generate the password digest.
// The algorithms we support at the moment are [bcrypt](https://en.wikipedia.org/wiki/Bcrypt), md5, pbkdf2_sha256, [pbkdf2_sha256_django](https://docs.djangoproject.com/en/4.0/topics/auth/passwords/), [scrypt_firebase](https://firebaseopensource.com/projects/firebase/scrypt/) and 2 [argon2](https://argon2.online/) variants, argon2i and argon2id.
// Each of the above expects the incoming digest to be of a particular format.
//
// More specifically:
//
// **bcrypt:** The digest should be of the following form:
//
// `$<algorithm version>$<cost>$<salt & hash>`
//
// **md5:** The digest should follow the regular form e.g.:
//
// `5f4dcc3b5aa765d61d8327deb882cf99`
//
// **pbkdf2_sha256:** This is the PBKDF2 algorithm using the SHA256 hashing function. The format should be as follows:
//
// `pbkdf2_sha256$<iterations>$<salt>$<hash>`
//
// Note: Both the salt and the hash are expected to be base64-encoded.
//
// **pbkdf2_sha256_django:** This is the Django-specific variant of PBKDF2 and the digest should have the following format (as exported from Django):
//
// `pbkdf2_sha256$<iterations>$<salt>$<hash>`
//
// Note: The salt is expected to be un-encoded, the hash is expected base64-encoded.
//
// **pbkdf2_sha1:** This is similar to pkbdf2_sha256_django, but with two differences:
// 1. uses sha1 instead of sha256
// 2. accepts the hash as a hex-encoded string
//
// The format is the following:
//
// `pbkdf2_sha1$<iterations>$<salt>$<hash-as-hex-string>`
//
//
// **scrypt_firebase:** The Firebase-specific variant of scrypt.
// The value is expected to have 6 segments separated by the $ character and include the following information:
//
// _hash:_ The actual Base64 hash. This can be retrieved when exporting the user from Firebase.
// _salt:_ The salt used to generate the above hash. Again, this is given when exporting the user.
// _signer key:_ The base64 encoded signer key.
// _salt separator:_ The base64 encoded salt separator.
// _rounds:_ The number of rounds the algorithm needs to run.
// _memory cost:_ The cost of the algorithm run
//
// The first 2 (hash and salt) are per user and can be retrieved when exporting the user from Firebase.
// The other 4 values (signer key, salt separator, rounds and memory cost) are project-wide settings and can be retrieved from the project's password hash parameters.
//
// Once you have all these, you can combine it in the following format and send this as the digest in order for Clerk to accept it:
//
// `<hash>$<salt>$<signer key>$<salt separator>$<rounds>$<memory cost>`
//
// **argon2i:** Algorithms in the argon2 family generate digests that encode the following information:
//
// _version (v):_ The argon version, version 19 is assumed
// _memory (m):_ The memory used by the algorithm (in kibibytes)
// _iterations (t):_ The number of iterations to perform
// _parallelism (p):_ The number of threads to use
//
// Parts are demarcated by the `$` character, with the first part identifying the algorithm variant.
// The middle part is a comma-separated list of the encoding options (memory, iterations, parallelism).
// The final part is the actual digest.
//
// `$argon2i$v=19$m=4096,t=3,p=1$4t6CL3P7YiHBtwESXawI8Hm20zJj4cs7/4/G3c187e0$m7RQFczcKr5bIR0IIxbpO2P0tyrLjf3eUW3M3QSwnLc`
//
// **argon2id:** See the previous algorithm for an explanation of the formatting.
//
// For the argon2id case, the value of the algorithm in the first part of the digest is `argon2id`:
//
// `$argon2id$v=19$m=64,t=4,p=8$Z2liZXJyaXNo$iGXEpMBTDYQ8G/71tF0qGjxRHEmR3gpGULcE93zUJVU`
//
// If you need support for any particular hashing algorithm, [please let us know](https://clerk.com/support).
// Enum: [bcrypt md5 pbkdf2_sha256 pbkdf2_sha256_django pbkdf2_sha1 scrypt_firebase argon2i argon2id]
PasswordHasher string `json:"password_hasher,omitempty"`
// Phone numbers to add to the user.
// Must be unique across your instance.
// The first phone number will be set as the user's primary phone number.
PhoneNumber []string `json:"phone_number"`
// Metadata saved on the user, that is only visible to your Backend API
PrivateMetadata interface{} `json:"private_metadata,omitempty"`
// Metadata saved on the user, that is visible to both your Frontend and Backend APIs
PublicMetadata interface{} `json:"public_metadata,omitempty"`
// When set to `true` all password checks are skipped.
// It is recommended to use this method only when migrating plaintext passwords to Clerk.
// Upon migration the user base should be prompted to pick stronger password.
SkipPasswordChecks bool `json:"skip_password_checks,omitempty"`
// When set to `true`, `password` is not required anymore when creating the user and can be omitted.
// This is useful when you are trying to create a user that doesn't have a password, in an instance that is using passwords.
// Please note that you cannot use this flag if password is the only way for a user to sign into your instance.
SkipPasswordRequirement bool `json:"skip_password_requirement,omitempty"`
// In case TOTP is configured on the instance, you can provide the secret to enable it on the newly created user without the need to reset it.
// Please note that currently the supported options are:
// * Period: 30 seconds
// * Code length: 6 digits
// * Algorithm: SHA1
TotpSecret string `json:"totp_secret,omitempty"`
// Metadata saved on the user, that can be updated from both the Frontend and Backend APIs.
// Note: Since this data can be modified from the frontend, it is not guaranteed to be safe.
UnsafeMetadata interface{} `json:"unsafe_metadata,omitempty"`
// The username to give to the user.
// It must be unique across your instance.
Username string `json:"username,omitempty"`
// Web3 wallets to add to the user.
// Must be unique across your instance.
// The first wallet will be set as the user's primary wallet.
Web3Wallet []string `json:"web3_wallet"`
}
// Validate validates this clerk user
func (m *ClerkUser) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validatePasswordHasher(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
var clerkUserTypePasswordHasherPropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["bcrypt","md5","pbkdf2_sha256","pbkdf2_sha256_django","pbkdf2_sha1","scrypt_firebase","argon2i","argon2id"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
clerkUserTypePasswordHasherPropEnum = append(clerkUserTypePasswordHasherPropEnum, v)
}
}
const (
// ClerkUserPasswordHasherBcrypt captures enum value "bcrypt"
ClerkUserPasswordHasherBcrypt string = "bcrypt"
// ClerkUserPasswordHasherMd5 captures enum value "md5"
ClerkUserPasswordHasherMd5 string = "md5"
// ClerkUserPasswordHasherPbkdf2Sha256 captures enum value "pbkdf2_sha256"
ClerkUserPasswordHasherPbkdf2Sha256 string = "pbkdf2_sha256"
// ClerkUserPasswordHasherPbkdf2Sha256Django captures enum value "pbkdf2_sha256_django"
ClerkUserPasswordHasherPbkdf2Sha256Django string = "pbkdf2_sha256_django"
// ClerkUserPasswordHasherPbkdf2Sha1 captures enum value "pbkdf2_sha1"
ClerkUserPasswordHasherPbkdf2Sha1 string = "pbkdf2_sha1"
// ClerkUserPasswordHasherScryptFirebase captures enum value "scrypt_firebase"
ClerkUserPasswordHasherScryptFirebase string = "scrypt_firebase"
// ClerkUserPasswordHasherArgon2i captures enum value "argon2i"
ClerkUserPasswordHasherArgon2i string = "argon2i"
// ClerkUserPasswordHasherArgon2id captures enum value "argon2id"
ClerkUserPasswordHasherArgon2id string = "argon2id"
)
// prop value enum
func (m *ClerkUser) validatePasswordHasherEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, clerkUserTypePasswordHasherPropEnum, true); err != nil {
return err
}
return nil
}
func (m *ClerkUser) validatePasswordHasher(formats strfmt.Registry) error {
if swag.IsZero(m.PasswordHasher) { // not required
return nil
}
// value enum
if err := m.validatePasswordHasherEnum("password_hasher", "body", m.PasswordHasher); err != nil {
return err
}
return nil
}
// ContextValidate validates this clerk user based on context it is used
func (m *ClerkUser) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *ClerkUser) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *ClerkUser) UnmarshalBinary(b []byte) error {
var res ClerkUser
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}