jitsi

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

README

Jitsi Slack - Jitsi Meet Integration for Slack

This project provides a Slack integration to enable starting video conferences from Slack and easily inviting Slack members to conferences.

Enables starting and joining Jitsi Meet meetings from within Slack

Getting Started

These instructions will get you started with the ability to run the project on your local machine for development purposes.

Prerequisites
Go

A working setup for the Go Programming Language is needed. Here is a getting started guide. The project is currently using go version 1.16 along with module support.

Slack

A slack account needs to be created as well as an app. The app created is intended for development purposes. The following functionality must be enabled in the Add features and functionality section of the slack app configuration:

  • App Home
    • Bot Name: 'jitsi_meet'
  • Slash Commands
    • set up '/jitsi' with: https://[server]/slash/jitsi
  • OAuth & Permissions
    • redirect URL: https://[server]/slack/auth
    • Scopes: chat:write, commands, im:write, users:read
  • Event Subscriptions:
    • request URL: https://[server]/slack/event
    • Subscribe to workspace events: 'app_uninstalled'

Note: This uses Slack v2 OAUTH 2.0. For legacy support, see: v0.1.2

Configuration

SLACK_SIGNING_SECRET=<signing secret of slack app>
SLACK_CLIENT_ID=<client id of slack app>
SLACK_CLIENT_SECRET=<client secret of slack app>
SLACK_APP_ID=<slack app id>
SLACK_APP_SHARABLE_URL=<slack app url for sharing install>
DYNAMO_REGION=<dynamodb region used>
TOKEN_TABLE=<dynamodb table name for storing oauth tokens>
SERVER_CFG_TABLE=<dynamodb table name for server config info>
JITSI_TOKEN_SIGNING_KEY=<key used to sign conference asap jwts>
JITSI_TOKEN_KID=<key identifier for conference asap jwts>
JITSI_TOKEN_ISS=<issuer for conference asap jwts>
JITSI_TOKEN_AUD=<audience for conference asap jwts>
JITSI_CONFERENCE_HOST=<conference hosting service i.e. https://meet.jit.si>
HTTP_PORT=<port to run HTTP, default is 8080>
STATS_PORT<port to serve Prometheus stats, default is to prevent stats>

Note that JITSI_TOKEN_SIGNING_KEY is a dataurl that contains a base64-encoded PKCS1 or PKCS8 key, and should look something like:

data:application/pkcs1;kid=[urlencoded kid];base64,[base64 pkcs1 key]

Running

Clone this project and build with go build cmd/api/main.go or build and run with go run cmd/api/main.go

Dependency Management

Dependency management for this project uses go module as of go version 1.16. More information can be found at go command documentation.

Versioning

This project uses Semantic Versioning for the code and associated docker containers. Versions are tracked as tags on this repository.

License

This project is licensed under the Apache 2.0 License LICENSE

Documentation

Index

Constants

View Source
const (
	// RequestTimestampHeader is the header key value for the slack request timestamp.
	RequestTimestampHeader = "X-Slack-Request-Timestamp"
	// RequestSignatureHeader is the header key value for the slack request signature.
	RequestSignatureHeader = "X-Slack-Signature"
	// SignatureVersion is the version of signature validation that is preformed.
	SignatureVersion = "v0"
)
View Source
const (
	// KeyTeamIDSrvCfg is the dynamo key for storing the team id.
	// This key is the primary index.
	KeyTeamIDSrvCfg = "team-id"
	// KeyServer is the dynamo key for storing the configured server.
	KeyServer = "server-url"
)
View Source
const (
	KeyTeamID      = "team-id"      // primary key; slack team id
	KeyAccessToken = "access-token" // oauth access token
)

Variables

This section is empty.

Functions

func RandomName

func RandomName() string

RandomName will generate a new video name randomly.

func ValidRequest

func ValidRequest(slackSigningSecret, requestBody, timestamp, slackSignature string) bool

ValidRequest returns a boolean indicating that a request is validated as originating from Slack.

Types

type EventHandler added in v0.1.1

type EventHandler struct {
	SlackSigningSecret string
	TokenWriter        TokenWriter
}

EventHandler is used to handle event callbacks from Slack api.

func (*EventHandler) Handle added in v0.1.1

func (e *EventHandler) Handle(w http.ResponseWriter, r *http.Request)

Handle handles event callbacks for the integration. adapated from https://github.com/slack-go/slack/blob/master/examples/eventsapi/events.go

type JWTInput added in v0.1.0

type JWTInput struct {
	TenantID   string
	TenantName string
	RoomClaim  string
	UserID     string
	UserName   string
	AvatarURL  string
}

JWTInput is the input required to generate a meeting JWT for a user.

type Meeting added in v0.1.0

type Meeting struct {
	RoomName         string
	URL              string
	Host             string
	AuthenticatedURL func(UserID, UserName, AvatarURL string) (string, error)
}

Meeting contains the server specific info for a meeting.

type MeetingGenerator added in v0.1.0

type MeetingGenerator struct {
	ServerConfigReader    ServerConfigReader
	MeetingTokenGenerator MeetingTokenGenerator
}

MeetingGenerator provides an interface for generating meetings configured correctly for the slack team.

func (*MeetingGenerator) New added in v0.1.0

func (m *MeetingGenerator) New(teamID, teamName string) (Meeting, error)

New generates a new meeting for the provided team. Each team may either be using the default service, meet.jit.si, or their own installation.

type MeetingTokenGenerator added in v0.1.0

type MeetingTokenGenerator interface {
	CreateJWT(JWTInput) (string, error)
}

MeetingTokenGenerator provides an interface for creating video conference authenticated access via JWT.

type ServerCfg added in v0.1.0

type ServerCfg struct {
	// Server is the host server for meetings. (e.g. https://meet.jit.si)
	Server string
	// TenantScopedURLs indicates whether or nto urls generated for meetings
	// on the server should be tenant scoped or not.
	// (e.g. https://meet.jit.si/team/room or https://meet.jit.si/room)
	TenantScopedURLs bool
	// AuthenticatedURLSupport indicates whether or not authenticated urls
	// are supported.
	AuthenticatedURLSupport bool
}

ServerCfg is the server configuration for a team.

type ServerCfgData added in v0.1.0

type ServerCfgData struct {
	TeamID string `json:"team-id"`
	Server string `json:"server-url"`
}

ServerCfgData is the server configuration data that is stored for teams.

type ServerCfgStore added in v0.1.0

type ServerCfgStore struct {
	// TableName is the name of the dynamo table where configuration is stored.
	TableName string
	// DB is the client used to access dynamodb.
	DB *dynamodb.Client
	// DefaultServer is the server host to use if none has been configured.
	DefaultServer string
	// TenantScopedURLs returns whether or not meeting urls should be
	// scoped with a tenant (e.g. https://meet.jit.si/tenant/room)
	TenantScopedURLs func(string) bool
	// AuthenticatedURLSupport returns whether or not the server supports
	// authenticated urls.
	AuthenticatedURLSupport func(string) bool
}

ServerCfgStore is used to store server configuration for teams.

func (*ServerCfgStore) Get added in v0.1.0

func (s *ServerCfgStore) Get(teamID string) (ServerCfg, error)

Get retrieves the server configuration for a team. This will provide the default if no configuration is stored for the team.

func (*ServerCfgStore) Remove added in v0.1.0

func (s *ServerCfgStore) Remove(teamID string) error

Remove will remove the persistent server configuration for a team. That team will use the defaults if no configuration is stored for the team.

func (*ServerCfgStore) Store added in v0.1.0

func (s *ServerCfgStore) Store(data *ServerCfgData) error

Store will persist a portion of the server configuration for a team.

type ServerConfigReader added in v0.1.0

type ServerConfigReader interface {
	Get(string) (ServerCfg, error)
}

ServerConfigReader provides an interface for reading configure server data from the configuration store.

type ServerConfigWriter added in v0.1.0

type ServerConfigWriter interface {
	Store(*ServerCfgData) error
	Remove(string) error
}

ServerConfigWriter provides an interface for writing server configuration data for a team's workspace.

type SlackOAuthHandlers

type SlackOAuthHandlers struct {
	ClientID     string
	ClientSecret string
	AppID        string
	TokenWriter  TokenWriter
}

SlackOAuthHandlers is used for handling Slack OAuth validation.

func (*SlackOAuthHandlers) Auth

Auth validates OAuth access tokens.

type SlashCommandHandlers

type SlashCommandHandlers struct {
	MeetingGenerator   *MeetingGenerator
	SlackSigningSecret string
	TokenReader        TokenReader
	TokenWriter        TokenWriter
	SharableURL        string
	ServerConfigWriter ServerConfigWriter
}

SlashCommandHandlers provides http handlers for Slack slash commands that integrate with Jitsi Meet.

func (*SlashCommandHandlers) Jitsi

Jitsi will create a conference and dispatch an invite message to both users. It is a slash command for Slack.

type TokenData

type TokenData struct {
	TeamID      string `json:"team-id"`
	AccessToken string `json:"access-token"`
}

TokenData is the access token data stored from oauth.

type TokenGenerator

type TokenGenerator struct {
	Lifetime   time.Duration
	PrivateKey string
	Issuer     string
	Audience   string
	Kid        string
}

TokenGenerator generates conference tokens for auth'ed users.

func (TokenGenerator) CreateJWT

func (g TokenGenerator) CreateJWT(in JWTInput) (string, error)

CreateJWT generates conference tokens for auth'ed users.

type TokenReader

type TokenReader interface {
	GetTokenForTeam(teamID string) (*TokenData, error)
}

TokenReader provides an interface for reading access token data from a token store.

type TokenStore

type TokenStore struct {
	TableName string
	DB        *dynamodb.Client
}

TokenStore stores and retrieves access tokens from aws dynamodb.

func (*TokenStore) GetTokenForTeam added in v0.1.1

func (t *TokenStore) GetTokenForTeam(teamID string) (*TokenData, error)

GetToken retrieves the access token stored with the provided team id.

func (*TokenStore) Remove added in v0.1.1

func (t *TokenStore) Remove(teamID string) error

Remove will remove access token data for the user.

func (*TokenStore) Store

func (t *TokenStore) Store(data *TokenData) error

Store will store access token data.

type TokenWriter

type TokenWriter interface {
	Store(data *TokenData) error
	Remove(teamID string) error
}

TokenWriter provides an interface to write access token data to the token store.

Directories

Path Synopsis
cmd
api

Jump to

Keyboard shortcuts

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