slack

package
v1.3.3-0...-f31c912 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlackApp

func NewSlackApp(conf *Config) *common.BaseApp

NewSlackApp initializes a new teleport-slack app and returns it.

Types

type APIResponse

type APIResponse struct {
	Ok    bool   `json:"ok"`
	Error string `json:"error,omitempty"`
}

type AccessResponse

type AccessResponse struct {
	APIResponse
	AccessToken      string `json:"access_token"`
	RefreshToken     string `json:"refresh_token"`
	ExpiresInSeconds int    `json:"expires_in"`
}

type ActionsBlock

type ActionsBlock struct {
	Elements []json.RawMessage `json:"elements"`
	BlockID  string            `json:"block_id,omitempty"`
}

func (ActionsBlock) BlockType

func (b ActionsBlock) BlockType() BlockType

type Authorizer

type Authorizer struct {
	// contains filtered or unexported fields
}

Authorizer implements oauth2.Authorizer for Slack API.

func NewAuthorizer

func NewAuthorizer(clientID string, clientSecret string) *Authorizer

NewAuthorizer returns a new Authorizer.

clientID is the Client ID for this Slack app as specified by OAuth2. clientSecret is the Client Secret for this Slack app as specified by OAuth2.

func (*Authorizer) Exchange

func (a *Authorizer) Exchange(ctx context.Context, authorizationCode string, redirectURI string) (*storage.Credentials, error)

Exchange implements oauth.Exchanger

func (*Authorizer) Refresh

func (a *Authorizer) Refresh(ctx context.Context, refreshToken string) (*storage.Credentials, error)

Refresh implements oauth.Refresher

type BaseMessage

type BaseMessage struct {
	Type      string `json:"type,omitempty"`
	Channel   string `json:"channel,omitempty"`
	User      string `json:"user,omitempty"`
	Username  string `json:"username,omitempty"`
	Timestamp string `json:"ts,omitempty"`
	ThreadTs  string `json:"thread_ts,omitempty"`
}

type Block

type Block interface {
	BlockType() BlockType
}

type BlockItem

type BlockItem struct{ Block }

func NewBlockItem

func NewBlockItem(block Block) BlockItem

func (BlockItem) MarshalJSON

func (p BlockItem) MarshalJSON() ([]byte, error)

func (*BlockItem) UnmarshalJSON

func (p *BlockItem) UnmarshalJSON(data []byte) error

type BlockType

type BlockType string

type Bot

type Bot struct {
	// contains filtered or unexported fields
}

Bot is a slack client that works with AccessRequest. It's responsible for formatting and posting a message on Slack when an action occurs with an access request: a new request popped up, or a request is processed/updated.

func (Bot) BroadcastAccessRequestMessage

func (b Bot) BroadcastAccessRequestMessage(ctx context.Context, recipients []common.Recipient, reqID string, reqData pd.AccessRequestData) (accessrequest.SentMessages, error)

BroadcastAccessRequestMessage posts request info to Slack with action buttons.

func (Bot) CheckHealth

func (b Bot) CheckHealth(ctx context.Context) error

func (Bot) FetchRecipient

func (b Bot) FetchRecipient(ctx context.Context, name string) (*common.Recipient, error)

func (Bot) PostReviewReply

func (b Bot) PostReviewReply(ctx context.Context, channelID, timestamp string, review types.AccessReview) error

func (Bot) SendReviewReminders

func (b Bot) SendReviewReminders(ctx context.Context, recipient common.Recipient, accessList *accesslist.AccessList) error

SendReviewReminders will send a review reminder that an access list needs to be reviewed.

func (Bot) SupportedApps

func (b Bot) SupportedApps() []common.App

SupportedApps are the apps supported by this bot.

func (Bot) UpdateMessages

func (b Bot) UpdateMessages(ctx context.Context, reqID string, reqData pd.AccessRequestData, slackData accessrequest.SentMessages, reviews []types.AccessReview) error

Expire updates request's Slack post with EXPIRED status and removes action buttons.

type ChatMsgResponse

type ChatMsgResponse struct {
	APIResponse
	Channel   string `json:"channel"`
	Timestamp string `json:"ts"`
	Text      string `json:"text"`
}

type Config

type Config struct {
	common.BaseConfig
	Slack               common.GenericAPIConfig
	AccessTokenProvider auth.AccessTokenProvider
	StatusSink          common.StatusSink
	// contains filtered or unexported fields
}

Config stores the full configuration for the teleport-slack plugin to run.

func LoadSlackConfig

func LoadSlackConfig(filepath string) (*Config, error)

LoadSlackConfig reads the config file, initializes a new SlackConfig struct object, and returns it. Optionally returns an error if the file is not readable, or if file format is invalid.

func (*Config) CheckAndSetDefaults

func (c *Config) CheckAndSetDefaults() error

CheckAndSetDefaults checks the config struct for any logical errors, and sets default values if some values are missing. If critical values are missing and we can't set defaults for them, this will return an error.

func (*Config) NewBot

func (c *Config) NewBot(clusterName, webProxyAddr string) (common.MessagingBot, error)

NewBot initializes the new Slack message generator (SlackBot) takes GenericAPIConfig as an argument.

type ContextBlock

type ContextBlock struct {
	ElementItems []ContextElementItem `json:"elements"`
	BlockID      string               `json:"block_id,omitempty"`
}

func (ContextBlock) BlockType

func (b ContextBlock) BlockType() BlockType

type ContextElement

type ContextElement interface {
	ContextElementType() ContextElementType
}

type ContextElementItem

type ContextElementItem struct{ ContextElement }

func NewContextElementItem

func NewContextElementItem(element ContextElement) ContextElementItem

func (ContextElementItem) MarshalJSON

func (p ContextElementItem) MarshalJSON() ([]byte, error)

func (*ContextElementItem) UnmarshalJSON

func (p *ContextElementItem) UnmarshalJSON(data []byte) error

type ContextElementType

type ContextElementType string

type DividerBlock

type DividerBlock struct {
	BlockID string `json:"block_id,omitempty"`
}

func (DividerBlock) BlockType

func (b DividerBlock) BlockType() BlockType

type FileBlock

type FileBlock struct {
	ExternalID string `json:"external_id"`
	Source     string `json:"source"`
	BlockID    string `json:"block_id,omitempty"`
}

func (FileBlock) BlockType

func (b FileBlock) BlockType() BlockType

type HeaderBlock

type HeaderBlock struct {
	Text    string `json:"text"`
	BlockID string `json:"block_id,omitempty"`
}

func (HeaderBlock) BlockType

func (b HeaderBlock) BlockType() BlockType

type ImageBlock

type ImageBlock struct {
	ImageURL string          `json:"image_url"`
	AltText  string          `json:"alt_text,omitempty"`
	Title    json.RawMessage `json:"title,omitempty"`
	BlockID  string          `json:"block_id,omitempty"`
}

func (ImageBlock) BlockType

func (b ImageBlock) BlockType() BlockType

type InputBlock

type InputBlock struct {
	Label          json.RawMessage `json:"label"`
	Element        json.RawMessage `json:"element"`
	DispatchAction bool            `json:"dispatch_action,omitempty"`
	BlockID        string          `json:"block_id,omitempty"`
	Hint           json.RawMessage `json:"hint,omitempty"`
	Optional       bool            `json:"optional,omitempty"`
}

func (InputBlock) BlockType

func (b InputBlock) BlockType() BlockType

type MarkdownObject

type MarkdownObject struct {
	Text     string `json:"text"`
	Verbatim bool   `json:"verbatim,omitempty"`
}

func (MarkdownObject) ContextElementType

func (t MarkdownObject) ContextElementType() ContextElementType

func (MarkdownObject) GetText

func (t MarkdownObject) GetText() string

func (MarkdownObject) TextObjectType

func (t MarkdownObject) TextObjectType() TextObjectType

type Message

type Message struct {
	BaseMessage
	BlockItems []BlockItem `json:"blocks,omitempty"`
	Text       string      `json:"text,omitempty"`
}

type PlainTextObject

type PlainTextObject struct {
	Text  string `json:"text"`
	Emoji bool   `json:"emoji,omitempty"`
}

func (PlainTextObject) ContextElementType

func (t PlainTextObject) ContextElementType() ContextElementType

func (PlainTextObject) GetText

func (t PlainTextObject) GetText() string

func (PlainTextObject) TextObjectType

func (t PlainTextObject) TextObjectType() TextObjectType

type SectionBlock

type SectionBlock struct {
	Text    TextObjectItem   `json:"text,omitempty"`
	BlockID string           `json:"block_id,omitempty"`
	Fields  []TextObjectItem `json:"fields,omitempty"`
}

func (SectionBlock) BlockType

func (b SectionBlock) BlockType() BlockType

type TextObject

type TextObject interface {
	TextObjectType() TextObjectType
	GetText() string
}

type TextObjectItem

type TextObjectItem struct{ TextObject }

func NewTextObjectItem

func NewTextObjectItem(object TextObject) TextObjectItem

func (TextObjectItem) MarshalJSON

func (p TextObjectItem) MarshalJSON() ([]byte, error)

func (*TextObjectItem) UnmarshalJSON

func (p *TextObjectItem) UnmarshalJSON(data []byte) error

type TextObjectType

type TextObjectType string

type User

type User struct {
	ID      string      `json:"id"`
	Name    string      `json:"name"`
	Profile UserProfile `json:"profile"`
}

type UserProfile

type UserProfile struct {
	Email string `json:"email"`
}

Jump to

Keyboard shortcuts

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