upspin.io: upspin.io/user Index | Files

package user

import "upspin.io/user"

Package user provides tools for parsing and validating user names.

Index

Package Files

user.go

func Clean Uses

func Clean(userName upspin.UserName) (upspin.UserName, error)

Clean returns the user name in canonical form as described by the comments for the Parse function.

func Parse Uses

func Parse(userName upspin.UserName) (user, suffix, domain string, err error)

Parse splits an upspin.UserName into user and domain and returns the pair. It also returns the "+" suffix part of the user name, if it has one. For example, given the user name

ann+backup@example.com

it would return the strings

"ann+backup" "backup" "example.com"

Parsed validates the name as an e-mail address and lower-cases the domain so it is canonical.

The rules are:

<name> := <user name>@<domain name>

<domain name> :=

- each . separated token < 64 characters
- character set for tokens [a-z0-9\-]
- final token at least two characters
- whole name < 254 characters
- characters are case insensitive
- final period is OK, but we remove it

We ignore the rules of punycode, which is defined in https://tools.ietf.org/html/rfc3490 .

<user name> :=

Names are validated and canonicalized by the UsernameCasePreserved profile of the RFC 7613, "Preparation, Enforcement, and Comparison of Internationalized Strings", also known as PRECIS.

Further restrictions are added here. The only ASCII punctuation characters that are legal are "!#$%&'*+-/=?^_{|}~", and a name that is only ASCII punctuation is rejected.

As a special case for use in Access and Group files, the name "*" is allowed.

Case is significant and spaces are not allowed.

The username suffix is tightly constrained: It uses the same character set as domains, but of course the spacing of periods is irrelevant.

Facebook and Google constrain usernames to [a-zA-Z0-9+-.], ignoring the period and, in Google only, ignoring everything from a plus sign onwards. We accept a superset of this but do not follow the "ignore" rules.

func ParseDomain Uses

func ParseDomain(domain string) (string, error)

ParseDomain parses the component of a user name after the '@', that is, the domain component of an email address. The rules are defined in the documentation for Parse except the domain name itself must be less than 255 bytes long.

func ParseUser Uses

func ParseUser(user string) (userName, suffix string, err error)

ParseUser parses the component of a user name before the '@', that is, the user component of an email address. The rules are defined in the documentation for Parse except that "*" is not a valid user and the user name itself must be less than 255 bytes long.

Package user imports 4 packages (graph) and is imported by 17 packages. Updated 2019-05-02. Refresh now. Tools for package owners.