Skip to content

Commit aa76340

Browse files
committed
fixed
1 parent bdd2d5f commit aa76340

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/jwt.zig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,26 @@ pub const JWTClaims = struct {
124124
};
125125

126126
pub fn getSigningMethod(name: []const u8) !type {
127+
if (utils.eq(name, "RS256")) {
128+
return SigningMethodRS256;
129+
}
130+
if (utils.eq(name, "RS384")) {
131+
return SigningMethodRS384;
132+
}
133+
if (utils.eq(name, "RS512")) {
134+
return SigningMethodRS512;
135+
}
136+
137+
if (utils.eq(name, "PS256")) {
138+
return SigningMethodPS256;
139+
}
140+
if (utils.eq(name, "PS384")) {
141+
return SigningMethodPS384;
142+
}
143+
if (utils.eq(name, "PS512")) {
144+
return SigningMethodPS512;
145+
}
146+
127147
if (utils.eq(name, "ES256")) {
128148
return SigningMethodES256;
129149
}
@@ -161,6 +181,14 @@ pub fn getTokenHeader(alloc: Allocator, token_string: []const u8) !token.Token.H
161181
}
162182

163183
test "getSigningMethod" {
184+
try testing.expectEqual(SigningMethodRS256, try getSigningMethod("RS256"));
185+
try testing.expectEqual(SigningMethodRS384, try getSigningMethod("RS384"));
186+
try testing.expectEqual(SigningMethodRS512, try getSigningMethod("RS512"));
187+
188+
try testing.expectEqual(SigningMethodPS256, try getSigningMethod("PS256"));
189+
try testing.expectEqual(SigningMethodPS384, try getSigningMethod("PS384"));
190+
try testing.expectEqual(SigningMethodPS512, try getSigningMethod("PS512"));
191+
164192
try testing.expectEqual(SigningMethodES256, try getSigningMethod("ES256"));
165193
try testing.expectEqual(SigningMethodES384, try getSigningMethod("ES384"));
166194

0 commit comments

Comments
 (0)