Documentation
¶
Overview ¶
Package validate defines an interface which must be implmented by credential validators.
Index ¶
- func ExecuteTemplate(template *template.Template, parts []string, params map[string]any) (map[string]string, error)
- func ReadTemplateFile(pathTempl *template.Template, lang string) (*template.Template, string, error)
- func ResolveTemplatePath(path string) (string, error)
- func ValidateHostURL(origUrl string) (string, error)
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecuteTemplate ¶ added in v0.22.0
func ExecuteTemplate(template *template.Template, parts []string, params map[string]any) (map[string]string, error)
ExecuteTemplate executes the given template with provided parameters. If parts is nil, executes the main template body. Otherwise, executes each named part and returns a map of part name to generated content.
func ReadTemplateFile ¶ added in v0.22.0
func ReadTemplateFile(pathTempl *template.Template, lang string) (*template.Template, string, error)
ReadTemplateFile reads and parses a template file given a path template and language.
func ResolveTemplatePath ¶ added in v0.22.0
ResolveTemplatePath resolves the given template path. If the path is absolute, returns it as is. If the path is relative, resolves it relative to the current working directory.
func ValidateHostURL ¶ added in v0.22.0
ValidateHostURL validates and normalizes host_url from settings.
Types ¶
type Validator ¶
type Validator interface {
// Init initializes the validator.
Init(jsonconf string) error
// IsInitialized returns true if the validator is initialized.
IsInitialized() bool
// PreCheck pre-validates the credential without sending an actual request for validation:
// check uniqueness (if appropriate), format, etc
// Returns normalized credential prefixed with an appropriate namespace prefix.
PreCheck(cred string, params map[string]any) (string, error)
// Request sends a request for validation to the user. Returns true if it's a new credential,
// false if it re-sent request for an existing unconfirmed credential.
// user: UID of the user making the request.
// cred: credential being validated, such as email or phone.
// lang: user's human language as repored in the session.
// resp: optional response if user already has it (i.e. captcha/recaptcha).
// tmpToken: temporary authentication token to include in the request.
Request(user t.Uid, cred, lang, resp string, tmpToken []byte) (bool, error)
// ResetSecret sends a message with instructions for resetting an authentication secret.
// cred: address to use for the message.
// scheme: authentication scheme being reset.
// lang: human language as reported in the session.
// tmpToken: temporary authentication token
// params: authentication params.
ResetSecret(cred, scheme, lang string, tmpToken []byte, params map[string]any) error
// Check checks validity of user's response.
// Returns the value of validated credential on success.
Check(user t.Uid, resp string) (string, error)
// Remove deletes or deactivates user's given value.
Remove(user t.Uid, value string) error
// Delete deletes user's record.
Delete(user t.Uid) error
// TempAuthScheme returns a temporary authentication method used by this validator.
// It should be either "code" or "token".
TempAuthScheme() (string, error)
}
Validator handles validation of user's credentials, like email or phone.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package email is a credential validator which uses an external SMTP server.
|
Package email is a credential validator which uses an external SMTP server. |
|
Package tel is an incomplete implementation of SMS or voice credential validator.
|
Package tel is an incomplete implementation of SMS or voice credential validator. |