Skip to content

Commit 94f3e6b

Browse files
authored
Merge pull request #8 from lambda-feedback/7-evaluation-function-authentication
API key authentication
2 parents 5f5faa1 + 5e665b6 commit 94f3e6b

32 files changed

Lines changed: 193 additions & 33 deletions

.mockery.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ packages:
2626
inpackage: True
2727
dir: "{{.InterfaceDir}}"
2828
interfaces:
29-
Dispatcher:
30-
# testonly: True
29+
Dispatcher:

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ GLOBAL OPTIONS:
4848
--log-level value set the log level. Options: debug, info, warn, error, panic, fatal. [$LOG_LEVEL]
4949
--version print the version
5050

51+
auth
52+
53+
--auth-key value, -k value the authentication key to use for incoming requests. [$AUTH_KEY]
54+
5155
function
5256

5357
--arg value, -a value [ --arg value, -a value ] additional arguments for to the worker process. [$FUNCTION_ARGS]

app/app.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package app
22

33
import (
4+
"github.com/urfave/cli/v2"
5+
"go.uber.org/fx"
6+
47
"github.com/lambda-feedback/shimmy/config"
58
"github.com/lambda-feedback/shimmy/internal/shell"
69
"github.com/lambda-feedback/shimmy/runtime"
710
"github.com/lambda-feedback/shimmy/util/conf"
811
"github.com/lambda-feedback/shimmy/util/logging"
9-
"github.com/urfave/cli/v2"
10-
"go.uber.org/fx"
1112
)
1213

1314
func New(ctx *cli.Context) (*shell.Shell, error) {

app/lambda/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77

88
"github.com/aws/aws-lambda-go/lambda"
99
"github.com/awslabs/aws-lambda-go-api-proxy/httpadapter"
10-
"github.com/lambda-feedback/shimmy/internal/server"
1110
"go.uber.org/fx"
1211
"go.uber.org/zap"
12+
13+
"github.com/lambda-feedback/shimmy/internal/server"
1314
)
1415

1516
// LambdaHandlerParams represents the parameters required for

app/lambda/module.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package lambda
22

33
import (
4+
"go.uber.org/fx"
5+
46
"github.com/lambda-feedback/shimmy/handler"
57
"github.com/lambda-feedback/shimmy/util/logging"
6-
"go.uber.org/fx"
78
)
89

910
func Module(config Config) fx.Option {

app/standalone/module.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package standalone
22

33
import (
4+
"go.uber.org/fx"
5+
46
"github.com/lambda-feedback/shimmy/handler"
57
"github.com/lambda-feedback/shimmy/internal/server"
68
"github.com/lambda-feedback/shimmy/util/logging"
7-
"go.uber.org/fx"
89
)
910

1011
func Module(config Config) fx.Option {

cmd/lambda.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cmd
22

33
import (
4+
"github.com/urfave/cli/v2"
5+
46
"github.com/lambda-feedback/shimmy/app"
57
"github.com/lambda-feedback/shimmy/app/lambda"
68
"github.com/lambda-feedback/shimmy/util/conf"
79
"github.com/lambda-feedback/shimmy/util/logging"
8-
"github.com/urfave/cli/v2"
910
)
1011

1112
var (

cmd/root.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"os"
77
"time"
88

9+
"github.com/urfave/cli/v2"
10+
"go.uber.org/zap"
11+
912
"github.com/lambda-feedback/shimmy/config"
1013
"github.com/lambda-feedback/shimmy/util/conf"
1114
"github.com/lambda-feedback/shimmy/util/logging"
12-
"github.com/urfave/cli/v2"
13-
"go.uber.org/zap"
1415
)
1516

1617
var (
@@ -35,6 +36,13 @@ functions on arbitrary, serverless platforms.`
3536
Usage: "set the log format. Options: production, development.",
3637
EnvVars: []string{"LOG_FORMAT"},
3738
},
39+
// auth flags
40+
&cli.StringFlag{
41+
Name: "auth-key",
42+
Usage: "the secret key for the application.",
43+
Category: "auth",
44+
EnvVars: []string{"AUTH_KEY"},
45+
},
3846
// shim flags
3947
&cli.StringFlag{
4048
Name: "interface",
@@ -241,6 +249,7 @@ func parseRootConfig(ctx *cli.Context) (config.Config, error) {
241249

242250
// map cli flags to config fields
243251
cliMap := map[string]string{
252+
"auth-key": "auth.key",
244253
"max-workers": "runtime.max_workers",
245254
"command": "runtime.cmd",
246255
"cwd": "runtime.cwd",

cmd/run.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ package cmd
33
import (
44
"os"
55

6-
"github.com/lambda-feedback/shimmy/util/logging"
76
"github.com/urfave/cli/v2"
7+
8+
"github.com/lambda-feedback/shimmy/util/logging"
89
)
910

1011
var (

cmd/serve.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
package cmd
22

33
import (
4+
"github.com/urfave/cli/v2"
5+
46
"github.com/lambda-feedback/shimmy/app"
57
"github.com/lambda-feedback/shimmy/app/standalone"
68
"github.com/lambda-feedback/shimmy/util/conf"
79
"github.com/lambda-feedback/shimmy/util/logging"
8-
"github.com/urfave/cli/v2"
910
)
1011

1112
var (

0 commit comments

Comments
 (0)