roles

package
v0.0.0-...-4fe5f23 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package roles are part of the Skia Infra Authorization system.

See go/proxy-auth-skia.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Role

type Role string

Role for an authorized user.

const (
	// Viewer has read-only access to the application.
	Viewer Role = "viewer"

	// Editor has read-write access to the application.
	Editor Role = "editor"

	// Admin has admin access to the application.
	Admin Role = "admin"

	// Bisecter can request a bisection.
	Bisecter Role = "bisecter"

	// Buildbucket represents the Buildbucket service.
	Buildbucket Role = "buildbucket"

	// LuciConfig represents the LUCI Config service account.
	LuciConfig Role = "luci_config"
)
const (
	// InvalidRole signals an invalid Role.
	InvalidRole Role = ""
)

func RoleFromString

func RoleFromString(s string) Role

RoleFromString converts a string to a Role, returning InvalidRole, which is the empty string, if the passed in value is not a valid role.

type Roles

type Roles []Role

Roles is a slice of Role.

var (
	// AllValidRoles is all valid Roles.
	AllValidRoles Roles = []Role{Viewer, Editor, Admin, Bisecter, Buildbucket, LuciConfig}

	// AllRoles is all Roles including InvalidRole.
	AllRoles Roles = append(AllValidRoles, InvalidRole)
)

func FromHeader

func FromHeader(s string) Roles

FromHeader parses a Roles header value and returns Roles found.

func RolesFromStrings

func RolesFromStrings(s ...string) Roles

RolesFromStrings parses multiple string values and returns Roles found.

func (Roles) Has

func (r Roles) Has(role Role) bool

Has returns true if the give Role appears in Roles.

func (Roles) IsAuthorized

func (r Roles) IsAuthorized(in Roles) bool

IsAuthorized returns true if r and in contain any of the same roles. Note that if either r or in is empty, this will return false.

func (Roles) ToHeader

func (r Roles) ToHeader() string

ToHeader converts Roles to a string, formatted for an HTTP header.

Jump to

Keyboard shortcuts

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