slackauth

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2016 License: MIT Imports: 11 Imported by: 0

README

slackauth

godoc reference Build Status codecov License

slackauth is a package to implement the "Add to Slack" button functionality in an easy way.

Install

go get gopkg.in/mvader/slackauth.v1

Example

service, err := slackauth.New(slackauth.Options{
	Addr:         ":8080",
	ClientID:     os.Getenv("CLIENT_ID"),
	ClientSecret: os.Getenv("CLIENT_SECRET"),
	SuccessTpl:   "success.html",
	ErrorTpl:     "error.html",
	Debug:        true,
})
if err != nil {
	log.Fatal(err)
}

service.OnAuth(func(auth *slack.OAuthResponse) {
	log15.Info("someone was authorized!", "team", auth.TeamName)
})

log.Fatal(service.Run())

See full example in the examples folder.

Documentation

Index

Constants

View Source
const (
	// BOT scope grants permission to add the bot bundled by the app
	BOT = "bot"
	// WEBHOOK scope  allows requesting permission to post content to the user's Slack team
	WEBHOOK = "incoming-webhook"
	// COMMANDS scope allows installing slash commands bundled in the Slack app
	COMMANDS = "commands"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Addr is the address where the service will run. e.g: :8080, 0.0.0.0:8989, etc.
	Addr string
	// ClientID is the slack client ID provided to you in your app credentials.
	ClientID string
	// ClientSecret is the slack client secret provided to you in your app credentials.
	ClientSecret string
	// SuccessTpl is the path to the template that will be displayed when there is a successful
	// auth.
	SuccessTpl string
	// ErrorTpl is the path to the template that will be displayed when there is an invalid
	// auth.
	ErrorTpl string
	// Debug will print some debug logs.
	Debug bool
	// CertFile is the path to the SSL certificate file. If this and KeyFile are provided, the
	// server will be run with SSL.
	CertFile string
	// KeyFile is the path to the SSL certificate key file. If this and CertFile are provided, the
	// server will be run with SSL.
	KeyFile string
	// ButtonTpl is the path to the Slack button template
	ButtonTpl string
	// Scopes is the list of the allowed scopes
	Scopes []string
}

Options has all the configurable parameters for slack authenticator.

type Service

type Service interface {
	// SetLogOutput sets the place where logs will be written.
	SetLogOutput(io.Writer)

	// Run will run the service. This method blocks until the service crashes or stops.
	Run() error

	// OnAuth sets the handler that will be triggered every time someone authorizes slack
	// successfully.
	OnAuth(func(*slack.OAuthResponse))
}

Service is a service to authenticate on slack using the "Add to slack" button.

func New

func New(opts Options) (Service, error)

New creates a new slackauth service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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