Documentation ¶
Index ¶
- Constants
- Variables
- func IsClientToken(tok string) bool
- func IsDocker() bool
- func IsInvalidAuthErr(err error) bool
- func ParseDotEnv(filename string) (string, string, error)
- func Save(w io.Writer, p Provider) error
- func WithContext(pctx context.Context, p Provider) context.Context
- type BrowserAuth
- type BrowserAuthUI
- type CookieFileAuth
- type Error
- type Option
- func BrowserWithAuthFlow(flow BrowserAuthUI) Option
- func BrowserWithBrowser(b browser.Browser) Option
- func BrowserWithTimeout(d time.Duration) Option
- func BrowserWithVerbose(b bool) Option
- func BrowserWithWorkspace(name string) Option
- func RODWithRODHeadlessTimeout(d time.Duration) Option
- func RODWithUserAgent(ua string) Option
- type Provider
- type RodAuth
- type ValueAuth
Constants ¶
const RODHeadlessTimeout = 40 * time.Second
RODHeadlessTimeout is the default timeout for the headless login flow. It is a net time of headless browser interaction, without the browser starting time.
const SlackURL = "https://slack.com"
Variables ¶
var ( ErrNoToken = errors.New("no token") ErrNoCookies = errors.New("no cookies") ErrNotSupported = errors.New("not supported") // ErrCancelled may be returned by auth providers, if the authentication // process was cancelled. ErrCancelled = errors.New("authentication cancelled") )
var ErrNoProvider = errors.New("internal error: no provider in context")
Functions ¶
func IsClientToken ¶
IsClientToken returns true if the tok is a web-client token.
func IsInvalidAuthErr ¶
Types ¶
type BrowserAuth ¶
type BrowserAuth struct {
// contains filtered or unexported fields
}
func NewBrowserAuth ¶
func NewBrowserAuth(ctx context.Context, opts ...Option) (BrowserAuth, error)
func (BrowserAuth) HTTPClient ¶
func (BrowserAuth) SlackToken ¶
func (c BrowserAuth) SlackToken() string
type BrowserAuthUI ¶
type CookieFileAuth ¶
type CookieFileAuth struct {
// contains filtered or unexported fields
}
func NewCookieFileAuth ¶
func NewCookieFileAuth(token string, cookieFile string) (CookieFileAuth, error)
NewCookieFileAuth creates new auth provider from token and Mozilla cookie file.
func (CookieFileAuth) HTTPClient ¶
func (CookieFileAuth) SlackToken ¶
func (c CookieFileAuth) SlackToken() string
type Error ¶
Error is the error returned by New, the underlying Err contains an API error returned by slack.AuthTest call.
type Option ¶
type Option func(*options)
func BrowserWithAuthFlow ¶
func BrowserWithAuthFlow(flow BrowserAuthUI) Option
func BrowserWithBrowser ¶
func BrowserWithTimeout ¶
func BrowserWithVerbose ¶
func BrowserWithWorkspace ¶
func RODWithRODHeadlessTimeout ¶
RODWithRODHeadlessTimeout sets the timeout for the headless browser interaction. It is a net time of headless browser interaction, without the browser starting time.
func RODWithUserAgent ¶
RODWithUserAgent sets the user agent string for the headless browser.
type Provider ¶
type Provider interface { // SlackToken should return the Slack Token value. SlackToken() string // Cookies should return a set of Slack Session cookies. Cookies() []*http.Cookie // Validate should return error, in case the token or cookies cannot be // retrieved. Validate() error // Test tests if credentials are valid. Test(ctx context.Context) (*slack.AuthTestResponse, error) // Client returns an authenticated HTTP client HTTPClient() (*http.Client, error) }
Provider is the Slack Authentication provider.
type RodAuth ¶
type RodAuth struct {
// contains filtered or unexported fields
}
RodAuth is an authentication provider that uses a headless or interactive browser to authenticate with Slack, depending on the user's choice. It uses rod library to drive the browser via the CDP protocol.
User can choose between:
- Email/password login - will be done headlessly
- SSO authentication - will open the browser and let the user do the thing.
- Cancel - will cancel the login flow.
Headless login is a bit fragile. If it fails, user should be advised to login interactively by choosing SSO auth type.
func NewRODAuth ¶
NewRODAuth constructs new RodAuth provider.
func (RodAuth) HTTPClient ¶
func (RodAuth) SlackToken ¶
func (c RodAuth) SlackToken() string
type ValueAuth ¶
type ValueAuth struct {
// contains filtered or unexported fields
}
ValueAuth stores Slack credentials.
func Load ¶
Load deserialises JSON data from reader and returns a ValueAuth, that can be used to authenticate Slackdump. It will return ErrNoToken or ErrNoCookie if the authentication information is missing.
func NewValueCookiesAuth ¶
func (ValueAuth) HTTPClient ¶
func (ValueAuth) SlackToken ¶
func (c ValueAuth) SlackToken() string
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
pwcompat
Package pwcompat provides a compatibility layer, so when the playwright-go team decides to break compatibility again, there's a place to write a workaround.
|
Package pwcompat provides a compatibility layer, so when the playwright-go team decides to break compatibility again, there's a place to write a workaround. |