Documentation
¶
Index ¶
- Variables
- func MatchHandle(pattern, handle string) bool
- func MatchResource(pattern, resource string) bool
- func SplitLocalDomain(address string) (local, domain string, err error)
- func ValidHandle(value string) bool
- type Options
- type UserService
- func (s *UserService) AddHandle(value string) error
- func (s *UserService) AddResource(value string) error
- func (s *UserService) Authorized(handle, method, rawurl string) bool
- func (s *UserService) Close() error
- func (s *UserService) Listed(handle string) bool
- func (s *UserService) Notify(handle, loginurl string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidHandle = errors.New("invalid handle") ErrInvalidResource = errors.New("invalid resource") ErrInvalidAddress = errors.New("invalid address") )
Portable errors
Functions ¶
func MatchHandle ¶ added in v0.4.0
MatchHandle reports wether handle matches the handle pattern. The pattern syntax is:
'bob@example.com' matches a single address '@example.com' matches any addresses with domain example.com '@' matches any address
func MatchResource ¶ added in v0.4.0
MatchResource reports wether handle matches the handle pattern. The pattern syntax is:
'/private' matches the resources '/private/' matches any resource in the subtree 'domain.tld:8080/private/' matches any resource in the subtree with host and port
func SplitLocalDomain ¶ added in v0.4.0
SplitLocalDomain splits an email address into local and domain.
Example ¶
package main import ( "fmt" "github.com/namsral/multipass/services/email" ) func main() { local, domain, err := email.SplitLocalDomain("bob@example.com") if err != nil { fmt.Println(err) } fmt.Println(local, domain) }
Output: bob example.com
func ValidHandle ¶ added in v0.4.0
ValidHandle reports wether value is a valid handle or handle pattern. The pattern syntax is:
'bob@example.com' matches a single address '@example.com' matches any addresses with domain example.com '@' matches any address
Types ¶
type Options ¶ added in v0.3.0
type Options struct { FromAddr string SMTPAddr, SMTPUser, SMTPPass string SMTPClientName string SMTPClientArgs []string MailTemplate string }
Options is used to construct a new UserService using the NewUserService function.
type UserService ¶ added in v0.3.0
type UserService struct {
// contains filtered or unexported fields
}
UserService implements the UserService interface. Handles are interperted as email addresses.
func NewUserService ¶ added in v0.3.0
func NewUserService(opt Options) (*UserService, error)
NewUserService returns a new UserService instance with the given options.
func (*UserService) AddHandle ¶ added in v0.4.0
func (s *UserService) AddHandle(value string) error
AddHandle registers the given handle or handle pattern to be used in user authorization.
func (*UserService) AddResource ¶ added in v0.4.0
func (s *UserService) AddResource(value string) error
AddResource adds the given resource or resource pattern to be used in user authorization.
func (*UserService) Authorized ¶ added in v0.3.0
func (s *UserService) Authorized(handle, method, rawurl string) bool
Authorized returns true when an user identified with the given handle is authorized to access the resource at the given rawurl. Unknown resources are accessible to listed and unlisted user handlers.
func (*UserService) Close ¶ added in v0.3.0
func (s *UserService) Close() error
Close closes the channel to send mail messages.
func (*UserService) Listed ¶ added in v0.3.0
func (s *UserService) Listed(handle string) bool
Listed return true when the given address is listed.
func (*UserService) Notify ¶ added in v0.3.0
func (s *UserService) Notify(handle, loginurl string) error
Notify returns nil when the given login URL is successfully sent to the given email address.