You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: auth.go
+79-4Lines changed: 79 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,9 @@ package main
25
25
import (
26
26
"fmt"
27
27
"io/ioutil"
28
+
"strconv"
28
29
"strings"
30
+
"time"
29
31
30
32
"github.com/spf13/cobra"
31
33
@@ -34,9 +36,10 @@ import (
34
36
35
37
var (
36
38
cmdAuth=&cobra.Command{
37
-
Use: "auth",
38
-
Short: "ArangoDB authentication helper commands",
39
-
Run: cmdShowUsage,
39
+
Use: "auth",
40
+
Short: "ArangoDB authentication helper commands",
41
+
PersistentPreRunE: persistentAuthPreFunE,
42
+
Run: cmdShowUsage,
40
43
}
41
44
cmdAuthHeader=&cobra.Command{
42
45
Use: "header",
@@ -51,6 +54,12 @@ var (
51
54
authOptionsstruct {
52
55
jwtSecretFilestring
53
56
userstring
57
+
paths []string
58
+
expstring
59
+
expDuration time.Duration
60
+
61
+
fieldsOverride []string
62
+
fieldsOverrideMapmap[string]interface{}
54
63
}
55
64
)
56
65
@@ -62,6 +71,9 @@ func init() {
62
71
pf:=cmdAuth.PersistentFlags()
63
72
pf.StringVar(&authOptions.jwtSecretFile, "auth.jwt-secret", "", "name of a plain text file containing a JWT secret used for server authentication")
64
73
pf.StringVar(&authOptions.user, "auth.user", "", "name of a user to authenticate as. If empty, 'super-user' authentication is used")
74
+
pf.StringSliceVar(&authOptions.paths, "auth.paths", nil, "a list of allowed pathes. The path must not include the '_db/DBNAME' prefix.")
75
+
pf.StringVar(&authOptions.exp, "auth.exp", "", "a time in which token should expire - based on current time in UTC. Supported units: h, m, s (default)")
76
+
pf.StringSliceVar(&authOptions.fieldsOverride, "auth.fields", nil, "a list of additional fields set in the token. This flags override one auto-generated in token")
65
77
}
66
78
67
79
// mustAuthCreateJWTToken creates a the JWT token based on authentication options.
0 commit comments