import "go.chromium.org/luci/auth/identity"
Package identity defines Identity type and related types and constants. Identity represents a caller that makes requests.
var KnownKinds = map[Kind]*regexp.Regexp{ Anonymous: regexp.MustCompile(`^anonymous$`), Bot: regexp.MustCompile(`^[0-9a-zA-Z_\-\.@]+$`), Project: regexp.MustCompile(`^[a-z0-9\-_]+$`), Service: regexp.MustCompile(`^[0-9a-zA-Z_\-\:\.]+$`), User: regexp.MustCompile(`^[0-9a-zA-Z_\-\.\+\%]+@[0-9a-zA-Z_\-\.]+$`), }
KnownKinds is mapping between Kind and regexp for identity values.
See also appengine/components/components/auth/model.py in luci-py.
Glob is glob like pattern that matches identity strings of some kind.
It is a string of the form "kind:<pattern>" where 'kind' is one of Kind constants and 'pattern' is a wildcard pattern to apply to identity name.
The only supported glob syntax is '*', which matches zero or more characters.
Case sensitive. Doesn't support multi-line strings or patterns. There's no way to match '*' itself.
MakeGlob ensures 'glob' string looks like a valid identity glob and returns it as Glob value.
Kind returns identity glob kind. If identity glob string is invalid returns Anonymous.
Match returns true if glob matches an identity. If identity string or identity glob string are invalid, returns false.
Pattern returns a pattern part of the identity glob. If the identity glob string is invalid returns empty string.
Preprocess splits the glob into its kind and a regexp against identity names.
For example "user:*@example.com" => ("user", "^.*@example\.com$"). Returns an error if the glob is malformed.
Validate checks that the identity glob string is well-formed.
Identity represents a caller that makes requests. A string of the form "kind:value" where 'kind' is one of Kind constant and meaning of 'value' depends on a kind (see comments for Kind values).
AnonymousIdentity represents anonymous user.
MakeIdentity ensures 'identity' string looks like a valid identity and returns it as Identity value.
Email returns user's email for identity with kind User or empty string for all other identity kinds. If identity string is undefined returns "".
Kind returns identity kind. If identity string is invalid returns Anonymous.
Validate checks that the identity string is well-formed.
Value returns a valued encoded in the identity, e.g. for User identity kind it is user's email address. If identity string is invalid returns "anonymous".
Kind is enumeration of known identity kinds. See Identity.
const ( // Anonymous kind means no identity information is provided. Identity value // is always 'anonymous'. Anonymous Kind = "anonymous" // Bot is used for bots authenticated via IP allowlist. Used primarily by // Swarming. Identity value encodes bot ID. Bot Kind = "bot" // Project is used to convey that the request from one LUCI project to another // is being made on behalf of some LUCI project. Identity value is project ID. Project Kind = "project" // Service is used for GAE apps using X-Appengine-Inbound-Appid header for // authentication. Identity value is GAE app id. Service Kind = "service" // User is used for regular users. Identity value is email address. User Kind = "user" )
Package identity imports 4 packages (graph) and is imported by 83 packages. Updated 2021-01-27. Refresh now. Tools for package owners.