Skip to content

Commit d1b58c7

Browse files
authored
Merge pull request #239 from shynome/features/ed25519-sign-method
support ed25519 sign method
2 parents 8f0d487 + 0f56c29 commit d1b58c7

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

generates/jwt_access.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ func (a *JWTAccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasi
7070
key = v
7171
} else if a.isHs() {
7272
key = a.SignedKey
73+
} else if a.isEd() {
74+
v, err := jwt.ParseEdPrivateKeyFromPEM(a.SignedKey)
75+
if err != nil {
76+
return "", "", err
77+
}
78+
key = v
7379
} else {
7480
return "", "", errors.New("unsupported sign method")
7581
}
@@ -102,3 +108,7 @@ func (a *JWTAccessGenerate) isRsOrPS() bool {
102108
func (a *JWTAccessGenerate) isHs() bool {
103109
return strings.HasPrefix(a.SignedMethod.Alg(), "HS")
104110
}
111+
112+
func (a *JWTAccessGenerate) isEd() bool {
113+
return strings.HasPrefix(a.SignedMethod.Alg(), "Ed")
114+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/fatih/structs v1.1.0 // indirect
99
github.com/gavv/httpexpect v2.0.0+incompatible
1010
github.com/go-session/session v3.1.2+incompatible
11-
github.com/golang-jwt/jwt v3.2.1+incompatible
11+
github.com/golang-jwt/jwt v3.2.2+incompatible
1212
github.com/google/go-querystring v1.0.0 // indirect
1313
github.com/google/uuid v1.1.1
1414
github.com/gorilla/websocket v1.4.2 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ github.com/go-session/session v3.1.2+incompatible h1:yStchEObKg4nk2F7JGE7KoFIrA/
1919
github.com/go-session/session v3.1.2+incompatible/go.mod h1:8B3iivBQjrz/JtC68Np2T1yBBLxTan3mn/3OM0CyRt0=
2020
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
2121
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
22+
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
23+
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
2224
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2325
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
2426
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=

0 commit comments

Comments
 (0)