Documentation
¶
Overview ¶
Package slack is the Slack credential provider: bot, user, app-level, refresh and configuration tokens, and incoming webhook URLs.
Slack tokens carry no checksum, so every family is matched on its exact shape. The numeric groups of a token name the workspace and the user or bot it was issued to; patty reports that offline. Verification is one auth.test call; revocation goes through auth.revoke with the token itself.
Index ¶
- Constants
- type Provider
- func (p *Provider) DryRunRevoke(ctx context.Context, tok detect.Token) error
- func (*Provider) Find(content []byte) []detect.Token
- func (*Provider) Kinds() []detect.KindInfo
- func (*Provider) LocalSources() detect.LocalSources
- func (*Provider) Name() string
- func (p *Provider) Revoke(ctx context.Context, tokens []detect.Token) error
- func (p *Provider) Verify(ctx context.Context, tok detect.Token) detect.Verification
Constants ¶
const ( // KindBot is a bot token (xoxb-). KindBot detect.Kind = "slack-bot-token" // KindUser is a user token (xoxp-). KindUser detect.Kind = "slack-user-token" // KindApp is an app-level token for Socket Mode and events (xapp-). KindApp detect.Kind = "slack-app-token" // KindRefresh is a refresh token of a rotating or configuration token (xoxe-1-). KindRefresh detect.Kind = "slack-refresh-token" // KindConfig is an app configuration token, which shares its shape with // the short-lived access token of an app that rotates tokens (xoxe.xoxb-1-, xoxe.xoxp-1-). KindConfig detect.Kind = "slack-config-token" // KindWebhook is an incoming webhook URL (https://hooks.slack.com/...). KindWebhook detect.Kind = "slack-webhook" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// APIURL is the Web API root, https://slack.com/api by default.
APIURL string
// HooksURL replaces the https://hooks.slack.com origin of webhook URLs
// when verifying them; tests point it at a local server.
HooksURL string
Client *http.Client
}
Provider implements detect.Provider for Slack.
func (*Provider) DryRunRevoke ¶
DryRunRevoke implements detect.DryRunRevoker with auth.revoke's test mode: Slack answers exactly as it would for the real request but leaves the token alone.
func (*Provider) Find ¶
Find implements detect.Provider. Five substring passes cover every family; the `xoxb-`, `xoxp-` and `xapp-` prefixes are followed by numeric ids whose lengths are checked exactly, so a `xoxb-` inside a `xoxe.xoxb-1-` token never matches on its own.
func (*Provider) LocalSources ¶
func (*Provider) LocalSources() detect.LocalSources
LocalSources implements detect.Provider: the environment variables the Slack SDKs read and the credentials file of the Slack CLI.
func (*Provider) Revoke ¶
Revoke implements detect.Revoker through auth.revoke, one call per token: the token authenticates the request that revokes it. Slack answers `ok: true, revoked: true` and rejects the token from then on; unlike GitHub it does not notify anyone.