Documentation
¶
Overview ¶
Package authz evaluates Artifactory's permission model (decision 0006): the admin flag, the union of grants to a user and their groups, permission targets with Ant include and exclude patterns, the anonymous user, and token scopes, which only ever remove actions but for applied-permissions/admin, an administrator's token whatever its subject. It is a library: handlers build a Decider per request and ask it questions.
Index ¶
- func TargetAllows(t types.Target, path string, folder bool) bool
- type Decider
- func (d *Decider) Actions(rt types.ResourceType, repo Repo, path string, folder bool) types.Actions
- func (d *Decider) Admin() bool
- func (d *Decider) Allows(rt types.ResourceType, repo Repo, path string, want types.Actions) bool
- func (d *Decider) AllowsFolder(rt types.ResourceType, repo Repo, path string, want types.Actions) bool
- func (d *Decider) Grantable(g types.Grants) types.Actions
- func (d *Decider) Groups() []string
- func (d *Decider) Holds(g types.Grants, want types.Actions) bool
- func (d *Decider) ManagesResources(ctx context.Context, users store.UserStore, groups store.GroupStore) (bool, error)
- func (d *Decider) RepoConfig(key string) bool
- func (d *Decider) RepoVisible(repo Repo) bool
- func (d *Decider) Self() (user string, groups []string)
- func (d *Decider) System(area string, want types.ScopeActions) bool
- type Pattern
- type Repo
- type RepoPatterns
- type Sources
- type Subject
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decider ¶
type Decider struct {
// contains filtered or unexported fields
}
Decider answers permission questions for one subject from one snapshot of the permissions.
func (*Decider) Actions ¶
func (d *Decider) Actions( rt types.ResourceType, repo Repo, path string, folder bool, ) types.Actions
Actions returns every action the subject holds on path in repo's resource. folder is true for a folder, which is also visible when a permitted path lies below it.
func (*Decider) Allows ¶
Allows reports whether the subject holds every action in want on a file at path.
func (*Decider) AllowsFolder ¶
func (d *Decider) AllowsFolder( rt types.ResourceType, repo Repo, path string, want types.Actions, ) bool
AllowsFolder is Allows for a folder.
func (*Decider) Grantable ¶
Grantable returns the actions the subject may grant or revoke in a permission section whose grants are g. An administrator may change any. A holder of MANAGE in g may change only the other actions it holds in g: Artifactory 7.x's default exclude-manage rule, without which a holder could hand out rights it lacks, or appoint and remove other managers (decision 0006). Anyone else may change none, so a holder of MANAGE in one section changes nothing in another.
func (*Decider) Groups ¶
Groups returns the groups the subject acts through: all of its groups, or those a token scope names.
func (*Decider) Holds ¶
Holds reports whether g grants every action in want to the subject, directly or through a group it acts as. It answers questions about a permission document itself (who may manage it), not about content.
func (*Decider) ManagesResources ¶
func (d *Decider) ManagesResources( ctx context.Context, users store.UserStore, groups store.GroupStore, ) (bool, error)
ManagesResources reports whether the subject holds the Manage Resources role (the user's resources_manager, a group's manage_resources), which lets it manage every permission (decision 0006). The role follows the identities the subject acts as, as a group's admin privileges do: the user's own flag needs a scope that keeps the user, a group's a scope that keeps the group, and a scope of resource entries alone keeps neither. The flags are read here, not in New, because only the permission APIs ask.
func (*Decider) RepoConfig ¶
RepoConfig reports whether a token scope lets the subject read a repository's configuration. Without a scope, or with applied permissions and no repo entries, the permissions alone decide; repo entries (repo:<key>:r) narrow that to the repositories they name.
func (*Decider) RepoVisible ¶
RepoVisible reports whether the subject may see repo in a listing and read its configuration (decision 0006). An administrator sees everything. A token scope with repo entries sees exactly the repositories they name. Otherwise the subject sees a repository it may read anywhere in, and every repository through the system:info:r scope.
func (*Decider) Self ¶
Self returns the user the subject is and the groups it belongs to or acts through, whose entries in a permission are its own (decision 0006). A token scope does not narrow them: a token that acts only through a group is still its user's, so editing the user's entry with it is still a holder editing its own grants.
func (*Decider) System ¶
func (d *Decider) System(area string, want types.ScopeActions) bool
System reports whether the subject may use a system capability (an area such as "info", "metrics" or "identities"): administrators may; anyone else only through a token's system scope covering the area and actions.
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a compiled Ant-style path pattern: '/' separates segments, "**" matches zero or more segments, '*' any run of characters within a segment, '?' exactly one character. Matching is case-sensitive and paths are relative to the repository root.
func CompilePattern ¶
CompilePattern compiles p. A leading '/' is ignored and a trailing '/' means everything below, as in Ant ("dir/" is "dir/**").
func (Pattern) Match ¶
Match reports whether the pattern matches path ("" is the repository root, which only patterns that can match zero segments match).
func (Pattern) MatchBelow ¶
MatchBelow reports whether the pattern could match some path below folder, so a listing can show the folders that lead to permitted content (Ant's matchPatternStart).
type Repo ¶
Repo identifies a permission target: a repository's key and class (local, remote, virtual, federated, distribution), or the fixed build-info or release-bundle repository of those resources. "<remote>-cache" is accepted for a remote's cache and resolves to the remote.
type RepoPatterns ¶
type RepoPatterns struct {
// contains filtered or unexported fields
}
RepoPatterns are a repository's include and exclude patterns: Ant patterns, comma-separated in the configuration. AQL filters what it finds with them, and the generic format refuses writes they reject.
func PatternsOf ¶
func PatternsOf(c repo.Config) RepoPatterns
PatternsOf compiles c's patterns. An unset or empty includesPattern includes everything, as Artifactory's default "**/*" does.
type Sources ¶
type Sources struct {
Permissions store.PermissionStore
Groups store.GroupStore
// AnonymousEnabled is the security.anonymous_access setting; the
// anonymous user's grants apply only while it is on.
AnonymousEnabled bool
}
Sources is what a Decider reads once per request.
type Subject ¶
type Subject struct {
Name string
Groups []string
Admin bool
Anonymous bool
// Scope is the scope of the token the request carries; nil for password
// authentication, which acts with everything the subject holds.
Scope *types.Scope
}
Subject is who a request acts as. Groups are the groups the subject belongs to; the token service (#74) may instead put a token's scoped groups here when it mints a token for a subject that is not a user.