Documentation ¶
Index ¶
- Variables
- func AuthReset(cacheDir string) error
- func EzLoginFlags() map[string]bool
- func ReadUsers(r io.Reader) (types.Users, error)
- type AuthData
- type AuthType
- type Credentials
- type ErrWorkspace
- type Manager
- func (m *Manager) Auth(ctx context.Context, name string, c Credentials) (auth.Provider, error)
- func (m *Manager) CacheChannels(teamID string, cc []slack.Channel) error
- func (m *Manager) CacheUsers(teamID string, uu []slack.User) error
- func (m *Manager) CreateAndSelect(ctx context.Context, prov auth.Provider) (string, error)
- func (m *Manager) Current() (string, error)
- func (m *Manager) Delete(name string) error
- func (m *Manager) Exists(name string) bool
- func (m *Manager) ExistsErr(name string) error
- func (m *Manager) FileInfo(name string) (fs.FileInfo, error)
- func (m *Manager) HasDefault() bool
- func (m *Manager) List() ([]string, error)
- func (m *Manager) LoadChannels(teamID string, maxAge time.Duration) ([]slack.Channel, error)
- func (m *Manager) LoadProvider(name string) (auth.Provider, error)
- func (m *Manager) LoadUsers(teamID string, maxAge time.Duration) ([]slack.User, error)
- func (m *Manager) Select(name string) error
- func (m *Manager) WalkUsers(userFn func(path string, r io.Reader) error) error
- type Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotTested = errors.New("warning, " + ezLogin + " is not tested on this OS, if it doesn't work, use manual login method") ErrUnsupported = errors.New("" + ezLogin + " is not supported on this OS, please use the manual login method") )
var ( ErrEmpty = errors.New("empty cache file") ErrExpired = errors.New("cache expired") )
Functions ¶
func EzLoginFlags ¶
EZLoginFlags is a diagnostic function that returns the map of flags that describe the EZ-Login feature.
Types ¶
type AuthData ¶
AuthData is the authentication data.
func (AuthData) AuthProvider ¶
func (c AuthData) AuthProvider(ctx context.Context, workspace string, opts ...auth.Option) (auth.Provider, error)
AuthProvider returns the appropriate auth Provider depending on the values of the token and cookie.
func (AuthData) Type ¶
Type returns the authentication type that should be used for the current slack creds. If the auth type wasn't tested on the system that the slackdump is being executed on it will return the valid type and ErrNotTested, so that this unfortunate fact could be relayed to the end-user. If the type of the authentication determined is not supported for the current system, it will return ErrUnsupported.
type Credentials ¶
type ErrWorkspace ¶
ErrWorkspace is the error returned by the workspace manager, it contains the workspace name, the error message and the underlying error.
func (*ErrWorkspace) Error ¶
func (ew *ErrWorkspace) Error() string
func (*ErrWorkspace) Unwrap ¶
func (ew *ErrWorkspace) Unwrap() error
Unwrap returns the underlying error.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the workspace manager. It is an abstraction over the directory with files with credentials for Slack workspaces.
There are several types of files that one could find in the managed directory:
- "provider.bin" - the default workspace file, it contains the credentials for the "default" workspace. It exists for historical reasons, for migration from the previous version of the slackdump. It contains credentials for the workspace that slackdump v2 was authenticated in.
- "*.bin" - other workspaces, the filename is the name of the workspace.
- "workspace.txt" - a pointer to the current workspace, it contains the current workspace name.
- "*.cache" - cache files, they contain the cache for users and channels.
func NewManager ¶
NewManager creates a new workspace manager over the directory dir. The directory is created with rwx------ permissions, if it does not exist.
TODO: test with empty dir.
func (*Manager) Auth ¶
Auth authenticates in the Slack Workspace "name" and saves credentials to the relevant file. It initialises the auth.Provider depending on provided slack credentials. It returns auth.Provider or an error. The logic diagram is available in the doc/diagrams/auth_flow.puml.
If the creds is empty, it attempts to load the stored credentials. If it finds them, it returns an initialised credentials provider. If not - it returns the auth provider according to the type of credentials determined by creds.AuthProvider, and saves them to an AES-256-CFB encrypted storage.
The storage is encrypted using the hash of the unique machine-ID, supplied by the operating system (see package encio), it makes it impossible use the stored credentials on another machine (including virtual), even another operating system on the same machine, unless it's a clone of the source operating system on which the credentials storage was created.
func (*Manager) CacheChannels ¶
CacheChannels saves channels to cache.
func (*Manager) CacheUsers ¶
CacheUsers saves users to user cache file for teamID.
func (*Manager) CreateAndSelect ¶
func (*Manager) Exists ¶
Exists returns true if the workspace with name "name" exists in the list of authenticated workspaces.
func (*Manager) ExistsErr ¶
ExistsErr checks if the workspace exists, and returns any errors that may occur.
func (*Manager) HasDefault ¶
func (*Manager) LoadChannels ¶
LoadChannels loads channel cache no older than maxAge.
func (*Manager) LoadProvider ¶
LoadProvider loads the file from disk without any checks.
type Option ¶
type Option func(m *Manager)
func WithAuthOpts ¶
WithAuthOpts allows to change the default Auth options, they will be passed to auth package..
func WithChannelCacheBase ¶
WithChannelCacheBase allows to change the default cache file name for channels cache.
func WithUserCacheBase ¶
WithUserCacheBase allows to change the default base name of "users.cache". If the filename is empty it's a noop. If the filename does not contain extension, ".cache" is appended.