user

package
v0.0.0-...-3f1964b Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 18

Documentation

Overview

Package user provides tools for parsing and validating user names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clean

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

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

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

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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