sequenceDiagram
autonumber
Panel->>+Twitch: onAuthorized
Twitch-->>-Panel: token
Panel->>+EBS: Authorization: Bearer token
Note left of Panel: Button click event
EBS-->>-Panel: Pavlok URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "net" | |
| "net/http" | |
| "net/url" | |
| "regexp" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var conf *ebs.Config | |
| func init() { | |
| conf = ebs.NewConfig() | |
| secret := os.Getenv("EXTENSION_SECRET") | |
| helper = newService(decodeSecret(secret)) | |
| } | |
| func main() { | |
| lambda.Start( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestPreflight(t *testing.T) { | |
| // prep test data | |
| conf := ebs.NewConfig() | |
| expectMethods := "POST, GET, OPTIONS, PUT" | |
| expectHeaders := "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization" | |
| expectOrigin := "" | |
| req := newTestRequest("OPTIONS") | |
| // run the handler logic | |
| result, err := ebs.MiddlewareCORS(conf, handler)(req) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ebs | |
| import ( | |
| "net/http" | |
| "github.com/aws/aws-lambda-go/events" | |
| ) | |
| type HandlerFunc func(events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ebs | |
| import ( | |
| "fmt" | |
| "os" | |
| ) | |
| // configuration | |
| // to make environment variables available to testing | |
| const EXTENSION_ID = "EXTENSION_ID" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestAccessControlAllowOrigin(t *testing.T) { | |
| // prepare data | |
| conf := ebs.NewConfig() | |
| conf.ExtensionId("HOSTNAME-TEST") | |
| expectMethods := "POST, GET, OPTIONS, PUT" | |
| expectHeaders := "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization" | |
| expectOrigin := "https://HOSTNAME-TEST.ext-twitch.tv" | |
| req := newTestRequest("GET") | |
| // run handler logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // extension secret is enforced by claims extraction | |
| cl, err := helper.claims(token) | |
| if err != nil { | |
| log.Print("Malformed claims meta data") | |
| return newResponse("Wrong authorization header", http.StatusUnauthorized), | |
| errors.New("claims") | |
| } | |
| log.Printf("Claims (ch/role): %s / %s", cl.ChannelID, cl.Role) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func TestWrongExtensionSecret(t *testing.T) { | |
| // prepare data | |
| wrongHeader := make(map[string]string) | |
| wrongHeader["Authorization"] = "Bearer WRONG-KEY" | |
| req := events.APIGatewayProxyRequest{ | |
| HTTPMethod: "GET", | |
| Body: "", | |
| Headers: wrongHeader, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Build Fluorine snap | |
| # 1. Save this as a file named Dockerfile (e.g., /tmp/Dockerfile) | |
| # 2. Build the container | |
| # cd /tmp/Dockerfile | |
| # docker build -t fluorine . | |
| # | |
| # The result Fluorine_1.2.5_amd64.snap file is inside the container /usr/local/fluorine/dist | |
| # 3. To copy the file, run the container with a mount argument: | |
| # docker run -ti --rm -v $PWD:/tmp/tocopy --entrypoint sh fluorine | |
| # >cp /usr/local/fluorine/dist/Fluorine_1.2.5_amd64.snap /tmp/tocopy/ |
NewerOlder