slack

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 8 Imported by: 0

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

View Source
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 New

func New() *Provider

New returns a Provider against the public Slack API.

func (*Provider) DryRunRevoke

func (p *Provider) DryRunRevoke(ctx context.Context, tok detect.Token) error

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

func (*Provider) Find(content []byte) []detect.Token

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) Kinds

func (*Provider) Kinds() []detect.KindInfo

Kinds implements detect.Provider.

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) Name

func (*Provider) Name() string

Name implements detect.Provider.

func (*Provider) Revoke

func (p *Provider) Revoke(ctx context.Context, tokens []detect.Token) error

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.

func (*Provider) Verify

func (p *Provider) Verify(ctx context.Context, tok detect.Token) detect.Verification

Verify implements detect.Provider with one auth.test call, or an empty post for webhooks. Only Slack's explicit invalid-token answers count as revoked; anything else that is not a clean acceptance is unknown.

Jump to

Keyboard shortcuts

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