go-dynamodb-basicauth-plugin

command module
v0.0.0-...-7c4fbd0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MPL-2.0 Imports: 10 Imported by: 0

README

go-dynamodb-basicauth-plugin

Built to be run natively as a package by Tyk Gateways.

This is coded to be run by Tyk as middleware, NOT custom auth. That code is available in another project.

This will authenticate requests by connecting to DynamoDB and checking the Basic Auth credentials in the request to see if they match what's in the DB. If success, will let the request continue, otherwise will return an auth error.

Setup AWS credentials in the GO Plugin

In here,

	sess, err := session.NewSession(&aws.Config{
		Region:      aws.String("us-east-2"),
		Credentials: credentials.NewStaticCredentials("AKID", "SECRET", ""),
	})

Replace AKID and SECRET with your AWS credentials. Leave the third parameter exactly as is, an empty string. Make sure the region is accurate also.

Generate the Binary file

In the root of the "main.go" file, run go build -o ./middleware/go/main.so -buildmode=plugin ./middleware/go Put the generated file somewhere Tyk Gateway can access it

Build Tyk to run GOPLUGINS

go build -tags 'coprocess grpc goplugin' -o tyk . you may only need goplugin in that list above

Then run the compiled Tyk

Setup your API

in API Designer, click on "Raw API Definition"

  1. Set "driver": "goplugin"
  2. Choose somewhere for your middleware to run in the cycle. ie:
"custom_middleware": {
      "pre": [
        {
          "name": "MyCustomPlugin",
          "path": "./middleware/go/helloworld.so"
        }
      ],

Pre is the phase in the cycle where it runs. "name" has to be the name of the GO function "path" is wherever you put the binary generated in step 1

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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