Skip to content

Commit 31ac168

Browse files
authored
Merge pull request #4 from peter-evans/0.4.0
0.4.0
2 parents b22e4ec + 2cc0f32 commit 31ac168

5 files changed

Lines changed: 158 additions & 72 deletions

File tree

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ payload_claims = {
8282
}
8383
footer_claims = { kid = "MDlCMUIwNzU4RTA2QzZFMDQ4" }
8484
claim_rules = {
85-
IssuedBy = "paragonie.com",
86-
IdentifiedBy = "87IFSGFgPNtQNNuw0AtuLttP",
87-
ForAudience = "some-audience.com",
88-
Subject = "test",
89-
NotExpired = true,
90-
ValidAt = true,
91-
ContainsClaim = "data",
92-
myclaim = "required value"
85+
claim_1 = { claim = "IssuedBy", value = "paragonie.com" },
86+
claim_2 = { claim = "IdentifiedBy", value = "87IFSGFgPNtQNNuw0AtuLttP" },
87+
claim_3 = { claim = "ForAudience", value = "some-audience.com" },
88+
claim_4 = { claim = "Subject", value = "test" },
89+
claim_5 = { claim = "NotExpired", value = "" },
90+
claim_6 = { claim = "ValidAt", value = "" },
91+
claim_7 = { claim = "ContainsClaim", value = "data" },
92+
claim_8 = { claim = "myclaim", value = "required value" }
9393
}
9494
9595
-- generate symmetric key
@@ -131,14 +131,14 @@ payload_claims = {
131131
}
132132
footer_claims = { kid = "MDlCMUIwNzU4RTA2QzZFMDQ4" }
133133
claim_rules = {
134-
IssuedBy = "paragonie.com",
135-
IdentifiedBy = "87IFSGFgPNtQNNuw0AtuLttP",
136-
ForAudience = "some-audience.com",
137-
Subject = "test",
138-
NotExpired = true,
139-
ValidAt = true,
140-
ContainsClaim = "data",
141-
myclaim = "required value"
134+
claim_1 = { claim = "IssuedBy", value = "paragonie.com" },
135+
claim_2 = { claim = "IdentifiedBy", value = "87IFSGFgPNtQNNuw0AtuLttP" },
136+
claim_3 = { claim = "ForAudience", value = "some-audience.com" },
137+
claim_4 = { claim = "Subject", value = "test" },
138+
claim_5 = { claim = "NotExpired", value = "" },
139+
claim_6 = { claim = "ValidAt", value = "" },
140+
claim_7 = { claim = "ContainsClaim", value = "data" },
141+
claim_8 = { claim = "myclaim", value = "required value" }
142142
}
143143
144144
-- generate key pair

paseto/v2.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local v2 = {
2-
_VERSION = 'paseto v0.3.0',
2+
_VERSION = 'paseto v0.4.0',
33
_DESCRIPTION = 'PASETO (Platform-Agnostic Security Tokens) for Lua',
44
_URL = 'https://github.com/peter-evans/paseto-lua',
55
_LICENSE = [[
@@ -149,14 +149,14 @@ local function validate_claims(payload_claims, claim_rules)
149149
if type(claim_rules) ~= "table" then
150150
return false, "Invalid claim rules format"
151151
end
152-
for key, value in pairs(claim_rules) do
153-
if registered_claims[key] ~= nil then
154-
local valid, err = registered_claims[key](payload_claims, value)
152+
for _, rule in pairs(claim_rules) do
153+
if registered_claims[rule.claim] ~= nil then
154+
local valid, err = registered_claims[rule.claim](payload_claims, rule.value)
155155
if valid == false then
156156
return false, err
157157
end
158158
else
159-
local matches, err = claim_matches_expected_value(payload_claims, key, value)
159+
local matches, err = claim_matches_expected_value(payload_claims, rule.claim, rule.value)
160160
if matches == false then
161161
return false, err
162162
end

paseto/v2/core.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local core = {
2-
_VERSION = 'paseto v0.3.0',
2+
_VERSION = 'paseto v0.4.0',
33
_DESCRIPTION = 'PASETO (Platform-Agnostic Security Tokens) for Lua',
44
_URL = 'https://github.com/peter-evans/paseto-lua',
55
_LICENSE = [[

rockspecs/paseto-0.4.0-1.rockspec

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package = "paseto"
2+
version = "0.4.0-1"
3+
description = {
4+
summary = "PASETO (Platform-Agnostic Security Tokens) for Lua",
5+
detailed = "PASETO (Platform-Agnostic SEcurity TOkens) is a specification and reference implementation for secure stateless tokens.",
6+
homepage = "http://github.com/peter-evans/paseto-lua",
7+
license = "MIT"
8+
}
9+
source = {
10+
url = "https://github.com/peter-evans/paseto-lua/archive/0.4.0.tar.gz",
11+
dir = "paseto-lua-0.4.0"
12+
}
13+
dependencies = {
14+
"lua >= 5.1, < 5.4",
15+
"basexx >= 0.4.0",
16+
"lua-struct >= 0.9.0",
17+
"lua-cjson >= 2.1.0",
18+
"date >= 2.1.2"
19+
}
20+
external_dependencies = {
21+
SODIUM = {
22+
header = "sodium.h"
23+
}
24+
}
25+
supported_platforms = {
26+
"linux"
27+
}
28+
build = {
29+
type = "builtin",
30+
modules = {
31+
["luasodium"] = {
32+
sources = { "csrc/luasodium.c" },
33+
libraries = { "sodium" },
34+
incdirs = { "$(SODIUM_INCDIR)" },
35+
libdirs = { "$(SODIUM_LIBDIR)" }
36+
},
37+
["paseto.v2"] = "paseto/v2.lua",
38+
["paseto.v2.core"] = "paseto/v2/core.lua"
39+
}
40+
}

0 commit comments

Comments
 (0)