Documentation
¶
Index ¶
- Variables
- type AccessToken
- type AuthCode
- type ConsoleAuthorization
- type ConsoleConfig
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(_ *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type IAMTokenResult
- type InMemoryBackend
- func (b *InMemoryBackend) CreateOAuth2Token(req TokenRequest) (*TokenResult, error)
- func (b *InMemoryBackend) CreateOAuth2TokenWithIAM(ctx context.Context, grantType, resource string) (*IAMTokenResult, error)
- func (b *InMemoryBackend) DeleteConsoleAuthorizationConfiguration(ctx context.Context, targetID string) (*ConsoleAuthorization, error)
- func (b *InMemoryBackend) DeleteResourcePermissionStatement(ctx context.Context, sid string) error
- func (b *InMemoryBackend) GetConsoleAuthorizationConfiguration(ctx context.Context, targetID string) (*ConsoleAuthorization, error)
- func (b *InMemoryBackend) GetResourcePolicy(ctx context.Context) ([]PolicyStatement, string, error)
- func (b *InMemoryBackend) IntrospectOAuth2Token(ctx context.Context, token, hint string) (*Introspection, error)
- func (b *InMemoryBackend) IssueAuthorizationCode(ctx context.Context, clientID, redirectURI, challenge, method string) (string, error)
- func (b *InMemoryBackend) ListResourcePermissionStatements(ctx context.Context, token string, maxResults int) (page.Page[PermissionStatement], error)
- func (b *InMemoryBackend) PutConsoleAuthorizationConfiguration(ctx context.Context, targetID string) (*ConsoleAuthorization, error)
- func (b *InMemoryBackend) PutResourcePermissionStatement(ctx context.Context, in StatementInput) (string, error)
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) ResolvePrincipal(_ context.Context, accessKeyID, sessionToken string) (*awsmeta.Principal, bool)
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) RevokeOAuth2Token(ctx context.Context, token string) error
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- type Introspection
- type PermissionStatement
- type PolicyStatement
- type Provider
- type Session
- type StatementInput
- type TokenRequest
- type TokenResult
Constants ¶
This section is empty.
Variables ¶
var ( // ErrValidation is returned for malformed or out-of-range input. ErrValidation = awserr.New("ValidationException", awserr.ErrInvalidParameter) // ErrNotFound is returned when the requested resource does not exist. ErrNotFound = awserr.New("ResourceNotFoundException", awserr.ErrNotFound) // ErrConflict is returned when the request conflicts with existing state. ErrConflict = awserr.New("ConflictException", awserr.ErrConflict) // ErrAccessDenied is returned when the caller or token may not perform the request. ErrAccessDenied = errors.New("AccessDeniedException") )
var ErrNilAppContext = errors.New("appContext must not be nil")
ErrNilAppContext is returned when Init is called with a nil application context.
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct {
IssuedAt time.Time `json:"issuedAt"`
ExpiresAt time.Time `json:"expiresAt"`
JTI string `json:"jti"`
Account string `json:"account"`
Subject string `json:"subject"`
UserID string `json:"userID"`
Audience string `json:"audience"`
SessionArn string `json:"sessionArn"`
}
AccessToken is a JWT access token issued by CreateOAuth2TokenWithIAM.
type AuthCode ¶
type AuthCode struct {
ExpiresAt time.Time `json:"expiresAt"`
Code string `json:"code"`
ClientID string `json:"clientID"`
RedirectURI string `json:"redirectURI"`
Challenge string `json:"challenge"`
Account string `json:"account"`
PrincipalArn string `json:"principalArn"`
UserID string `json:"userID"`
SessionKey string `json:"sessionKey,omitempty"`
Used bool `json:"used"`
}
AuthCode is a single-use authorization code awaiting redemption.
type ConsoleAuthorization ¶
ConsoleAuthorization is the state returned by the console authorization operations.
type ConsoleConfig ¶
type ConsoleConfig struct {
TargetID string `json:"targetID"`
Scope string `json:"scope"`
Enabled bool `json:"enabled"`
}
ConsoleConfig is the console authorization configuration of an account or organization target.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// contains filtered or unexported fields
}
Handler is the Echo handler for the Sign-In REST-JSON API.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a handler over backend.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions served.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for the request.
func (*Handler) ExtractResource ¶
ExtractResource returns the primary resource identifier (none for Sign-In).
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the implemented SDK operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler function.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches the Sign-In paths. They carry no service prefix and the token calls are sent unsigned, so the SigV4 signing name, the SDK user agent or the sign-in host is required.
type IAMTokenResult ¶
IAMTokenResult is the CreateOAuth2TokenWithIAM result.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend is the in-memory Sign-In backend. One coarse lock guards all tables.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend with a fresh token signing key.
func (*InMemoryBackend) CreateOAuth2Token ¶
func (b *InMemoryBackend) CreateOAuth2Token(req TokenRequest) (*TokenResult, error)
CreateOAuth2Token redeems an authorization code or refreshes a session.
func (*InMemoryBackend) CreateOAuth2TokenWithIAM ¶
func (b *InMemoryBackend) CreateOAuth2TokenWithIAM( ctx context.Context, grantType, resource string, ) (*IAMTokenResult, error)
CreateOAuth2TokenWithIAM exchanges the caller's identity for a resource-scoped JWT access token.
func (*InMemoryBackend) DeleteConsoleAuthorizationConfiguration ¶
func (b *InMemoryBackend) DeleteConsoleAuthorizationConfiguration( ctx context.Context, targetID string, ) (*ConsoleAuthorization, error)
DeleteConsoleAuthorizationConfiguration removes the target's configuration.
func (*InMemoryBackend) DeleteResourcePermissionStatement ¶
func (b *InMemoryBackend) DeleteResourcePermissionStatement(ctx context.Context, sid string) error
DeleteResourcePermissionStatement removes a statement from the caller's policy.
func (*InMemoryBackend) GetConsoleAuthorizationConfiguration ¶
func (b *InMemoryBackend) GetConsoleAuthorizationConfiguration( ctx context.Context, targetID string, ) (*ConsoleAuthorization, error)
GetConsoleAuthorizationConfiguration returns the target's configuration.
func (*InMemoryBackend) GetResourcePolicy ¶
func (b *InMemoryBackend) GetResourcePolicy(ctx context.Context) ([]PolicyStatement, string, error)
GetResourcePolicy returns the caller's consolidated policy document.
func (*InMemoryBackend) IntrospectOAuth2Token ¶
func (b *InMemoryBackend) IntrospectOAuth2Token(ctx context.Context, token, hint string) (*Introspection, error)
IntrospectOAuth2Token reports the state of an access or refresh token owned by the caller's account.
func (*InMemoryBackend) IssueAuthorizationCode ¶
func (b *InMemoryBackend) IssueAuthorizationCode( ctx context.Context, clientID, redirectURI, challenge, method string, ) (string, error)
IssueAuthorizationCode mints a single-use code bound to the caller, client, redirect URI and PKCE challenge.
func (*InMemoryBackend) ListResourcePermissionStatements ¶
func (b *InMemoryBackend) ListResourcePermissionStatements( ctx context.Context, token string, maxResults int, ) (page.Page[PermissionStatement], error)
ListResourcePermissionStatements pages through the caller's statements.
func (*InMemoryBackend) PutConsoleAuthorizationConfiguration ¶
func (b *InMemoryBackend) PutConsoleAuthorizationConfiguration( ctx context.Context, targetID string, ) (*ConsoleAuthorization, error)
PutConsoleAuthorizationConfiguration enables console authorization for the target.
func (*InMemoryBackend) PutResourcePermissionStatement ¶
func (b *InMemoryBackend) PutResourcePermissionStatement(ctx context.Context, in StatementInput) (string, error)
PutResourcePermissionStatement adds a statement; replays of the same request return the same statement.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the default region.
func (*InMemoryBackend) Reset ¶
func (b *InMemoryBackend) Reset()
Reset clears all state; the signing key is kept so outstanding JWTs stay verifiable.
func (*InMemoryBackend) ResolvePrincipal ¶
func (b *InMemoryBackend) ResolvePrincipal( _ context.Context, accessKeyID, sessionToken string, ) (*awsmeta.Principal, bool)
ResolvePrincipal resolves credentials issued by CreateOAuth2Token to the principal that signed in.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads state produced by Snapshot.
func (*InMemoryBackend) RevokeOAuth2Token ¶
func (b *InMemoryBackend) RevokeOAuth2Token(ctx context.Context, token string) error
RevokeOAuth2Token revokes a refresh token; unknown, expired or foreign tokens succeed silently.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the time source (tests).
type Introspection ¶
type Introspection struct {
Iss string
Session string
Aud string
ClientID string
UserID string
Jti string
Sub string
TokenType string
Account string
Resource string
Nbf int64
Iat int64
Exp int64
Active bool
}
Introspection is the RFC 7662 result; only Active is set for an inactive token.
type PermissionStatement ¶
type PermissionStatement struct {
CreatedAt time.Time `json:"createdAt"`
Condition map[string]map[string][]string `json:"condition"`
Key string `json:"key"`
Account string `json:"account"`
SID string `json:"sid"`
ClientToken string `json:"clientToken"`
Fingerprint string `json:"fingerprint"`
ConsoleSourceVpce string `json:"consoleSourceVpce,omitempty"`
ExcludedPrincipal string `json:"excludedPrincipal,omitempty"`
RequestedRegion string `json:"requestedRegion,omitempty"`
SigninSourceVpce string `json:"signinSourceVpce,omitempty"`
SourceIP string `json:"sourceIp,omitempty"`
SourceVpc string `json:"sourceVpc,omitempty"`
VpcSourceIP string `json:"vpcSourceIp,omitempty"`
}
PermissionStatement is one statement of an account's Sign-In resource-based policy.
type PolicyStatement ¶
type PolicyStatement struct {
Condition map[string]map[string][]string
Principal map[string]string
Effect string
Resource string
Action []string
}
PolicyStatement is one statement of the resource-based policy document.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for AWS Sign-In.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler.
type Session ¶
type Session struct {
CreatedAt time.Time `json:"createdAt"`
RefreshExpiresAt time.Time `json:"refreshExpiresAt"`
CredsExpireAt time.Time `json:"credsExpireAt"`
RefreshToken string `json:"refreshToken"`
SessionID string `json:"sessionID"`
Account string `json:"account"`
Region string `json:"region"`
PrincipalArn string `json:"principalArn"`
UserID string `json:"userID"`
ClientID string `json:"clientID"`
AccessKeyID string `json:"accessKeyID"`
SecretKey string `json:"secretKey"`
SessionToken string `json:"sessionToken"`
Revoked bool `json:"revoked"`
}
Session is a human OAuth session: a refresh token plus the credentials minted from it.
type StatementInput ¶
type StatementInput struct {
ClientToken string
ConsoleSourceVpce string
ExcludedPrincipal string
RequestedRegion string
SigninSourceVpce string
SourceIP string
SourceVpc string
VpcSourceIP string
}
StatementInput is the PutResourcePermissionStatement request.