auth/jwt: add claim factory to example
hbc
5 years ago
12 | 12 | ```go |
13 | 13 | import ( |
14 | 14 | stdjwt "github.com/dgrijalva/jwt-go" |
15 | ||
15 | ||
16 | 16 | "github.com/go-kit/kit/auth/jwt" |
17 | 17 | "github.com/go-kit/kit/endpoint" |
18 | 18 | ) |
22 | 22 | { |
23 | 23 | kf := func(token *stdjwt.Token) (interface{}, error) { return []byte("SigningString"), nil } |
24 | 24 | exampleEndpoint = MakeExampleEndpoint(service) |
25 | exampleEndpoint = jwt.NewParser(kf, stdjwt.SigningMethodHS256)(exampleEndpoint) | |
25 | exampleEndpoint = jwt.NewParser(kf, stdjwt.SigningMethodHS256, jwt.StandardClaimsFactory)(exampleEndpoint) | |
26 | 26 | } |
27 | 27 | } |
28 | 28 | ``` |
34 | 34 | ```go |
35 | 35 | import ( |
36 | 36 | stdjwt "github.com/dgrijalva/jwt-go" |
37 | ||
37 | ||
38 | 38 | "github.com/go-kit/kit/auth/jwt" |
39 | 39 | "github.com/go-kit/kit/endpoint" |
40 | 40 | ) |
44 | 44 | { |
45 | 45 | exampleEndpoint = grpctransport.NewClient(...).Endpoint() |
46 | 46 | exampleEndpoint = jwt.NewSigner( |
47 | "kid-header", | |
48 | []byte("SigningString"), | |
49 | stdjwt.SigningMethodHS256, | |
47 | "kid-header", | |
48 | []byte("SigningString"), | |
49 | stdjwt.SigningMethodHS256, | |
50 | 50 | jwt.Claims{}, |
51 | 51 | )(exampleEndpoint) |
52 | 52 | } |
66 | 66 | import ( |
67 | 67 | stdjwt "github.com/dgrijalva/jwt-go" |
68 | 68 | |
69 | grpctransport "github.com/go-kit/kit/transport/grpc" | |
69 | grpctransport "github.com/go-kit/kit/transport/grpc" | |
70 | 70 | "github.com/go-kit/kit/auth/jwt" |
71 | 71 | "github.com/go-kit/kit/endpoint" |
72 | 72 | ) |