Documentation ¶
Index ¶
- Constants
- func EncodeUserIdentifier(subject string) string
- func GetDefaultUserNamespace(provider ResourceProvider, signup signup.Signup) string
- func IsPhoneVerificationRequired(captchaChecker captcha.Assessor, ctx *gin.Context) (bool, float32)
- func NewSignupService(context servicecontext.ServiceContext, opts ...SignupServiceOption) service.SignupService
- type ResourceProvider
- type ServiceImpl
- func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, provider ResourceProvider, userID, username string, ...) (*signup.Signup, error)
- func (s *ServiceImpl) DoGetUserSignupFromIdentifier(provider ResourceProvider, userID, username string) (*toolchainv1alpha1.UserSignup, error)
- func (s *ServiceImpl) GetSignup(ctx *gin.Context, userID, username string) (*signup.Signup, error)
- func (s *ServiceImpl) GetSignupFromInformer(ctx *gin.Context, userID, username string, checkUserSignupCompleted bool) (*signup.Signup, error)
- func (s *ServiceImpl) GetUserSignupFromIdentifier(userID, username string) (*toolchainv1alpha1.UserSignup, error)
- func (s *ServiceImpl) PhoneNumberAlreadyInUse(userID, username, phoneNumberOrHash string) error
- func (s *ServiceImpl) Signup(ctx *gin.Context) (*toolchainv1alpha1.UserSignup, error)
- func (s *ServiceImpl) UpdateUserSignup(userSignup *toolchainv1alpha1.UserSignup) (*toolchainv1alpha1.UserSignup, error)
- type SignupServiceOption
Constants ¶
const ( DNS1123NameMaximumLength = 63 // NoSpaceKey is the query key for specifying whether the UserSignup should be created without a Space NoSpaceKey = "no-space" )
Variables ¶
This section is empty.
Functions ¶
func EncodeUserIdentifier ¶
EncodeUserIdentifier transforms a subject value (the user's UserID) to make it DNS-1123 compliant, by removing invalid characters, trimming the length and prefixing with a CRC32 checksum if required. ### WARNING ### changing this function will cause breakage, as it is used to lookup existing UserSignup resources. If a change is absolutely required, then all existing UserSignup instances must be migrated to the new value
func GetDefaultUserNamespace ¶
func GetDefaultUserNamespace(provider ResourceProvider, signup signup.Signup) string
func IsPhoneVerificationRequired ¶
IsPhoneVerificationRequired determines whether phone verification is required
Returns true in the following cases: 1. Captcha configuration is disabled 2. The captcha token is invalid 3. Captcha failed with an error or the assessment failed
Returns false in the following cases: 1. Overall verification configuration is disabled 2. User's email domain is excluded 3. Captcha is enabled and the assessment is successful
Returns true/false to dictate whether phone verification is required. Returns the captcha score if the assessment was successful, otherwise returns -1 which will prevent the score from being set in the UserSignup annotation.
func NewSignupService ¶
func NewSignupService(context servicecontext.ServiceContext, opts ...SignupServiceOption) service.SignupService
NewSignupService creates a service object for performing user signup-related activities.
Types ¶
type ResourceProvider ¶
type ResourceProvider interface { GetMasterUserRecord(name string) (*toolchainv1alpha1.MasterUserRecord, error) GetToolchainStatus() (*toolchainv1alpha1.ToolchainStatus, error) GetUserSignup(name string) (*toolchainv1alpha1.UserSignup, error) GetSpace(name string) (*toolchainv1alpha1.Space, error) ListSpaceBindings(reqs ...labels.Requirement) ([]toolchainv1alpha1.SpaceBinding, error) }
type ServiceImpl ¶
type ServiceImpl struct { base.BaseService CaptchaChecker captcha.Assessor // contains filtered or unexported fields }
ServiceImpl represents the implementation of the signup service.
func (*ServiceImpl) DoGetSignup ¶
func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, provider ResourceProvider, userID, username string, checkUserSignupCompleted bool) (*signup.Signup, error)
func (*ServiceImpl) DoGetUserSignupFromIdentifier ¶
func (s *ServiceImpl) DoGetUserSignupFromIdentifier(provider ResourceProvider, userID, username string) (*toolchainv1alpha1.UserSignup, error)
GetUserSignupFromIdentifier is used to return the actual UserSignup resource instance, rather than the Signup DTO
func (*ServiceImpl) GetSignup ¶
GetSignup returns Signup resource which represents the corresponding K8s UserSignup and MasterUserRecord resources in the host cluster. Returns nil, nil if the UserSignup resource is not found or if it's deactivated.
func (*ServiceImpl) GetSignupFromInformer ¶
func (s *ServiceImpl) GetSignupFromInformer(ctx *gin.Context, userID, username string, checkUserSignupCompleted bool) (*signup.Signup, error)
GetSignupFromInformer uses the same logic of the 'GetSignup' function, except it uses informers to get resources. This function and the ResourceProvider abstraction can replace the original GetSignup function once it is determined to be stable. The checkUserSignupCompleted was introduced in order to avoid checking the readiness of the complete condition on the UserSignup in certain situations, such as proxy calls for example.
func (*ServiceImpl) GetUserSignupFromIdentifier ¶
func (s *ServiceImpl) GetUserSignupFromIdentifier(userID, username string) (*toolchainv1alpha1.UserSignup, error)
GetUserSignupFromIdentifier is used to return the actual UserSignup resource instance, rather than the Signup DTO
func (*ServiceImpl) PhoneNumberAlreadyInUse ¶
func (s *ServiceImpl) PhoneNumberAlreadyInUse(userID, username, phoneNumberOrHash string) error
PhoneNumberAlreadyInUse checks if the phone number has been banned. If so, return an internal server error. If not, check if an active (non-deactivated) UserSignup with a different userID and username and email address exists. If so, return an internal server error. Otherwise, return without error. Either the actual phone number, or the md5 hash of the phone number may be provided here.
func (*ServiceImpl) Signup ¶
func (s *ServiceImpl) Signup(ctx *gin.Context) (*toolchainv1alpha1.UserSignup, error)
Signup reactivates the deactivated UserSignup resource or creates a new one with the specified username and userID if doesn't exist yet.
func (*ServiceImpl) UpdateUserSignup ¶
func (s *ServiceImpl) UpdateUserSignup(userSignup *toolchainv1alpha1.UserSignup) (*toolchainv1alpha1.UserSignup, error)
UpdateUserSignup is used to update the provided UserSignup resource, and returning the updated resource
type SignupServiceOption ¶
type SignupServiceOption func(svc *ServiceImpl)