service

package
v0.0.0-...-690bb9c Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
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

func EncodeUserIdentifier(subject string) string

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 GetDefaultUserTarget

func GetDefaultUserTarget(cl namespaced.Client, spaceName, murName string) (string, string)

GetDefaultUserTarget retrieves the target cluster and the default namespace from the Space a user has access to. If no spaceName is provided (assuming that this is the home space the target information should be taken from) then the logic lists all Spaces user has access to and picks the first one. returned values are:

  1. name of the member cluster the Space is provisioned to
  2. the name of the default namespace

If the user doesn't have access to any Space, then empty strings are returned

func IsPhoneVerificationRequired

func IsPhoneVerificationRequired(captchaChecker captcha.Assessor, ctx *gin.Context) (bool, float32, string)

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.

Returns the assessment ID if a captcha assessment was completed

func NewSignupService

func NewSignupService(client namespaced.Client, opts ...SignupServiceOption) service.SignupService

NewSignupService creates a service object for performing user signup-related activities.

Types

type ServiceImpl

type ServiceImpl struct {
	namespaced.Client
	CaptchaChecker captcha.Assessor
}

ServiceImpl represents the implementation of the signup service.

func (*ServiceImpl) DoGetSignup

func (s *ServiceImpl) DoGetSignup(ctx *gin.Context, cl namespaced.Client, userID, username string, checkUserSignupCompleted bool) (*signup.Signup, error)

func (*ServiceImpl) DoGetUserSignupFromIdentifier

func (s *ServiceImpl) DoGetUserSignupFromIdentifier(cl namespaced.Client, userID, username string) (*toolchainv1alpha1.UserSignup, error)

GetUserSignupFromIdentifier is used to return the actual UserSignup resource instance, rather than the Signup DTO

func (*ServiceImpl) GetSignup

func (s *ServiceImpl) GetSignup(ctx *gin.Context, userID, username string, checkUserSignupCompleted bool) (*signup.Signup, error)

GetSignup returns Signup resource which represents the corresponding K8s UserSignup and MasterUserRecord resources in the host cluster. 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. Returns nil, nil if the UserSignup resource is not found or if it's deactivated.

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 approved 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

Signup reactivates the deactivated UserSignup resource or creates a new one with the specified username and userID if doesn't exist yet.

type SignupServiceOption

type SignupServiceOption func(svc *ServiceImpl)

Jump to

Keyboard shortcuts

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