auth

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptChromiumCookie

func DecryptChromiumCookie(data []byte, password string, iterations int) (string, error)

DecryptChromiumCookie decrypts a Chromium cookie value using PBKDF2 + AES-128-CBC.

func DecryptCookieWindows

func DecryptCookieWindows(encrypted []byte, slackDataDir string) (string, error)

DecryptCookieWindows decrypts a Chromium cookie on Windows using DPAPI + AES-256-GCM. This is a placeholder — Windows support requires os/exec PowerShell calls.

func GetSafeStoragePasswords

func GetSafeStoragePasswords(prefix string) []string

GetSafeStoragePasswords retrieves Chromium Safe Storage passwords from the system keychain.

func IsEnterpriseURL added in v0.1.4

func IsEnterpriseURL(u string) bool

IsEnterpriseURL returns true if the URL is an Enterprise Grid org-level URL.

func KeychainGet

func KeychainGet(account, service string) string

KeychainGet reads a password from macOS keychain.

func KeychainSet

func KeychainSet(account, value, service string) bool

KeychainSet stores a password in macOS keychain.

func NormalizeURL

func NormalizeURL(u string) (string, error)

NormalizeURL returns canonical workspace URL.

func QueryReadonlySQLite

func QueryReadonlySQLite(dbPath, query string) ([]map[string]any, error)

QueryReadonlySQLite copies a SQLite DB (to avoid locking) and runs a query.

func RemoveWorkspace

func RemoveWorkspace(workspaceURL string) error

RemoveWorkspace removes a workspace from credentials.

func SaveCredentials

func SaveCredentials(creds *Credentials) error

SaveCredentials writes credentials to disk.

func SetDefaultWorkspace

func SetDefaultWorkspace(workspaceURL string) error

SetDefaultWorkspace sets the default workspace.

func UpsertWorkspace

func UpsertWorkspace(ws Workspace) error

UpsertWorkspace adds or updates a workspace in credentials.

func UpsertWorkspaces

func UpsertWorkspaces(workspaces []Workspace) error

UpsertWorkspaces upserts multiple workspaces.

Types

type BraveExtracted

type BraveExtracted struct {
	CookieD string
	Teams   []BrowserTeam
}

BraveExtracted holds tokens extracted from Brave browser.

func ExtractFromBrave

func ExtractFromBrave() *BraveExtracted

ExtractFromBrave extracts Slack auth from Brave browser (macOS only).

type BrowserTeam

type BrowserTeam struct {
	URL              string `json:"url"`
	Name             string `json:"name,omitempty"`
	Token            string `json:"token"`
	EnterpriseID     string `json:"enterprise_id,omitempty"`
	EnterpriseDomain string `json:"enterprise_domain,omitempty"`
}

BrowserTeam represents a team extracted from a browser.

type ChromeExtracted

type ChromeExtracted struct {
	CookieD string
	Teams   []BrowserTeam
}

ChromeExtracted holds tokens extracted from Chrome.

func ExtractFromChrome

func ExtractFromChrome() *ChromeExtracted

ExtractFromChrome extracts Slack auth from Google Chrome. Primary: reads Cookie DB + LevelDB directly (no AppleScript needed). Fallback: AppleScript on macOS if DB method fails.

type Credentials

type Credentials struct {
	Version    int         `json:"version"`
	Default    string      `json:"default,omitempty"`
	Workspaces []Workspace `json:"workspaces"`
}

Credentials holds all workspace credentials.

func LoadCredentials

func LoadCredentials() (*Credentials, error)

LoadCredentials reads the stored credentials file.

type DesktopExtracted

type DesktopExtracted struct {
	CookieD string
	Teams   []BrowserTeam
	Source  DesktopSource
}

DesktopExtracted holds tokens extracted from Slack Desktop.

func ExtractFromDesktop

func ExtractFromDesktop() (*DesktopExtracted, error)

ExtractFromDesktop extracts Slack auth from Slack Desktop application.

type DesktopSource

type DesktopSource struct {
	LevelDBPath string
	CookiesPath string
}

type FirefoxExtracted

type FirefoxExtracted struct {
	CookieD string
	Teams   []BrowserTeam
	Source  FirefoxSource
}

FirefoxExtracted holds tokens extracted from Firefox.

func ExtractFromFirefox

func ExtractFromFirefox(profileSelector string) *FirefoxExtracted

ExtractFromFirefox extracts Slack auth from Firefox profiles.

type FirefoxSource

type FirefoxSource struct {
	ProfilePath      string
	CookiesPath      string
	LocalStoragePath string
}

type ParsedCurlTokens

type ParsedCurlTokens struct {
	WorkspaceURL string
	XoxcToken    string
	XoxdCookie   string
}

ParsedCurlTokens holds tokens extracted from a cURL command.

func ParseSlackCurlCommand

func ParseSlackCurlCommand(curlInput string) (*ParsedCurlTokens, error)

ParseSlackCurlCommand extracts tokens from a cURL command string.

type Workspace

type Workspace struct {
	WorkspaceURL  string     `json:"workspace_url"`
	WorkspaceName string     `json:"workspace_name,omitempty"`
	Auth          slack.Auth `json:"auth"`
}

Workspace represents a stored workspace with credentials.

func ResolveClient

func ResolveClient(workspaceSelector string) (*slack.Client, *Workspace, error)

ResolveClient resolves a Slack API client from available credential sources. Priority: env vars → stored creds (selector match) → default workspace.

func ResolveDefaultWorkspace

func ResolveDefaultWorkspace() (*Workspace, error)

ResolveDefaultWorkspace returns the default workspace.

func ResolveEnterpriseClient added in v0.1.8

func ResolveEnterpriseClient() (*slack.Client, *Workspace, error)

ResolveEnterpriseClient finds a stored workspace with an enterprise URL and returns a client for it. Used as fallback for APIs that require enterprise-level access (e.g. client.counts).

func ResolveWorkspaceForURL

func ResolveWorkspaceForURL(workspaceURL string) (*Workspace, error)

ResolveWorkspaceForURL finds a workspace by URL.

func ResolveWorkspaceSelector

func ResolveWorkspaceSelector(selector string) (*Workspace, error)

ResolveWorkspaceSelector does fuzzy matching on workspace URL/name.

Jump to

Keyboard shortcuts

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