Documentation ¶
Overview ¶
Package tokens manages token authentication
Index ¶
- func NewService(opts Options) (*service, error)
- func NewSessionToken(key jwk.Key, username string, expiry time.Time) (string, error)
- func NewTestJWT(t *testing.T, secret []byte, kind Kind, lifetime time.Duration, ...) string
- func NewTestSessionJWT(t *testing.T, username string, secret []byte, lifetime time.Duration) string
- func NewToken(opts NewTokenOptions) ([]byte, error)
- type AgentToken
- func (t *AgentToken) CanAccessOrganization(action rbac.Action, name string) bool
- func (*AgentToken) CanAccessSite(action rbac.Action) bool
- func (t *AgentToken) CanAccessWorkspace(action rbac.Action, policy internal.WorkspacePolicy) bool
- func (t *AgentToken) IsOwner(string) bool
- func (t *AgentToken) IsSiteAdmin() bool
- func (t *AgentToken) Organizations() []string
- func (t *AgentToken) String() string
- type Client
- type CreateAgentTokenOptions
- type CreateRunTokenOptions
- type CreateUserTokenOptions
- type GoogleIAPConfig
- type Kind
- type NewAgentTokenOptions
- type NewTokenOptions
- type NewUserTokenOptions
- type Options
- type OrganizationService
- type RunToken
- func (t *RunToken) CanAccessOrganization(action rbac.Action, name string) bool
- func (t *RunToken) CanAccessSite(action rbac.Action) bool
- func (t *RunToken) CanAccessWorkspace(action rbac.Action, policy internal.WorkspacePolicy) bool
- func (t *RunToken) ID() string
- func (t *RunToken) IsOwner(string) bool
- func (t *RunToken) IsSiteAdmin() bool
- func (t *RunToken) Organizations() []string
- func (t *RunToken) String() string
- type RunTokenService
- type StartSessionOptions
- type TokensService
- type UserToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewSessionToken ¶
func NewTestJWT ¶
func NewTestSessionJWT ¶
func NewToken ¶
func NewToken(opts NewTokenOptions) ([]byte, error)
Types ¶
type AgentToken ¶
AgentToken represents the authentication token for an external agent. NOTE: the cryptographic token itself is not retained.
func AgentFromContext ¶
func AgentFromContext(ctx context.Context) (*AgentToken, error)
AgentFromContext retrieves an agent token from a context
func NewAgentToken ¶
func NewAgentToken(opts NewAgentTokenOptions) (*AgentToken, []byte, error)
NewAgentToken constructs a token for an external agent, returning both the representation of the token, and the cryptographic token itself.
TODO(@leg100): Unit test this.
func NewTestAgentToken ¶
func NewTestAgentToken(t *testing.T, org string) *AgentToken
func (*AgentToken) CanAccessOrganization ¶
func (t *AgentToken) CanAccessOrganization(action rbac.Action, name string) bool
func (*AgentToken) CanAccessSite ¶
func (*AgentToken) CanAccessSite(action rbac.Action) bool
func (*AgentToken) CanAccessWorkspace ¶
func (t *AgentToken) CanAccessWorkspace(action rbac.Action, policy internal.WorkspacePolicy) bool
func (*AgentToken) IsOwner ¶
func (t *AgentToken) IsOwner(string) bool
func (*AgentToken) IsSiteAdmin ¶
func (t *AgentToken) IsSiteAdmin() bool
func (*AgentToken) Organizations ¶
func (t *AgentToken) Organizations() []string
func (*AgentToken) String ¶
func (t *AgentToken) String() string
type Client ¶
type Client struct {
internal.JSONAPIClient
}
func (*Client) CreateAgentToken ¶
func (*Client) CreateRunToken ¶
CreateRunToken creates a run token via HTTP/JSONAPI
func (*Client) GetAgentToken ¶
type CreateAgentTokenOptions ¶
type CreateRunTokenOptions ¶
type CreateUserTokenOptions ¶
type CreateUserTokenOptions struct {
Description string
}
CreateUserTokenOptions are options for creating a user token via the service endpoint
type GoogleIAPConfig ¶
type GoogleIAPConfig struct {
Audience string
}
type Kind ¶
type Kind string
the Kind of authentication token: user session, user token, agent token, etc
type NewAgentTokenOptions ¶
type NewAgentTokenOptions struct { CreateAgentTokenOptions // contains filtered or unexported fields }
type NewTokenOptions ¶
type NewUserTokenOptions ¶
type NewUserTokenOptions struct { CreateUserTokenOptions Username string // contains filtered or unexported fields }
NewUserTokenOptions are options for constructing a user token via the constructor.
type OrganizationService ¶
type OrganizationService organization.Service
Aliases to disambiguate service names when embedded together.
type RunToken ¶
type RunToken struct {
Organization string
}
RunToken is a short-lived token providing a terraform run with access to resources, in particular access to the registry to retrieve modules.
func (*RunToken) CanAccessOrganization ¶
func (*RunToken) CanAccessWorkspace ¶
func (*RunToken) IsSiteAdmin ¶
func (*RunToken) Organizations ¶
type RunTokenService ¶
type RunTokenService interface {
CreateRunToken(ctx context.Context, opts CreateRunTokenOptions) ([]byte, error)
}
type StartSessionOptions ¶
type TokensService ¶
type TokensService interface { Middleware() mux.MiddlewareFunc RunTokenService // contains filtered or unexported methods }