Skip to content

Commit 2323f53

Browse files
authored
Merge pull request #80 from vcstuff/feature/zlib
switch to deflate + zlib instead of gzip
2 parents 4c646d4 + e393142 commit 2323f53

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

draft-ietf-oauth-status-list.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ normative:
2727
RFC7519: RFC7519
2828
RFC8392: RFC8392
2929
RFC3986: RFC3986
30-
RFC1952: RFC1952
30+
RFC1950: RFC1950
31+
RFC1951: RFC1951
3132
RFC7515: RFC7515
3233
RFC6125: RFC6125
3334
RFC9110: RFC9110
@@ -130,9 +131,9 @@ Each status of a Referenced Token MUST be represented with a bit size of 1,2,4,
130131

131132
1. The overall Status List is encoded as a byte array. Depending on the bitsize, each byte corresponds to 8/(#bit-size) statuses (8,4,2, or 1). The status of each Referenced Token is identified using the index that maps to one or more specific bits within the byte array. The index starts counting at 0 and ends with "size" - 1 (being the last valid entry). The bits within an array are counted from least significant bit "0" to the most significant bit ("7"). All bits of the byte array at a particular index are set to a status value.
132133

133-
2. The complete byte array is compressed using gZIP {{RFC1952}}.
134+
2. The complete byte array is compressed using the "DEFLATE" {{RFC1951}} compression method and stored using the "ZLIB" {{RFC1950}} data format. Implementations are RECOMMENDED to use the highest compression level available.
134135

135-
3. The result of the gZIP compression is then base64url-encoded, as defined in Section 2 of {{RFC7515}}.
136+
3. The result of the compression is then base64url-encoded, as defined in Section 2 of {{RFC7515}}.
136137

137138
## Referenced Token Format and Processing Requirements {#jwt-referenced-token}
138139

@@ -461,6 +462,11 @@ for their valuable contributions, discussions and feedback to this specification
461462
# Document History
462463
{:numbered="false"}
463464

465+
-01
466+
467+
* Changing compression from gzip to zlib
468+
* Change typo in Status List Token sub claim description
469+
464470
-00
465471

466472
* Initial draft after working group adoption

src/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
key = util.EXAMPLE_KEY
88
iat = datetime.utcfromtimestamp(1686920170)
99
exp = iat + timedelta(days=7000)
10-
gzip_time = iat.timestamp()
1110
folder = "./examples/"
1211

1312

@@ -29,7 +28,7 @@ def statusListEncoding1Bit():
2928
status_list.set(13, 1)
3029
status_list.set(14, 0)
3130
status_list.set(15, 1)
32-
encoded = status_list.encode(mtime=gzip_time)
31+
encoded = status_list.encode()
3332
text = 'byte_array = [{}, {}] \nencoded = "{}"'.format(
3433
hex(status_list.list[0]), hex(status_list.list[1]), encoded
3534
)
@@ -55,7 +54,7 @@ def exampleStatusList() -> StatusList:
5554

5655
def statusListEncoding2Bit():
5756
status_list = exampleStatusList()
58-
encoded = status_list.encode(mtime=gzip_time)
57+
encoded = status_list.encode()
5958
text = 'byte_array = [{}, {}, {}] \nencoded = "{}"'.format(
6059
hex(status_list.list[0]),
6160
hex(status_list.list[1]),
@@ -74,7 +73,7 @@ def statusListJWT():
7473
key=key,
7574
bits=2,
7675
)
77-
status_jwt = jwt.buildJWT(iat=iat, exp=exp, mtime=gzip_time)
76+
status_jwt = jwt.buildJWT(iat=iat, exp=exp)
7877
text = util.formatToken(status_jwt, key)
7978
util.outputFile(folder + "status_list_jwt", text)
8079

src/status_list.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from base64 import urlsafe_b64decode, urlsafe_b64encode
2-
import gzip
2+
import zlib
33

44

55
class StatusList:
@@ -20,13 +20,13 @@ def fromEncoded(cls, encoded: str, bits: int = 1):
2020
new.decode(encoded)
2121
return new
2222

23-
def encode(self, mtime=None) -> str:
24-
zipped = gzip.compress(self.list, mtime=mtime)
23+
def encode(self) -> str:
24+
zipped = zlib.compress(self.list, level=9)
2525
return urlsafe_b64encode(zipped).decode().strip("=")
2626

2727
def decode(self, input: str):
2828
zipped = urlsafe_b64decode(f"{input}{'=' * divmod(len(input),4)[1]}")
29-
self.list = bytearray(gzip.decompress(zipped))
29+
self.list = bytearray(zlib.decompress(zipped))
3030
self.size = len(self.list) * self.divisor
3131

3232
def set(self, pos: int, value: int):

src/status_token.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ def buildJWT(
7575
exp: datetime = None,
7676
optional_claims: Dict = None,
7777
optional_header: Dict = None,
78-
compact=True,
79-
mtime=None,
78+
compact=True
8079
) -> str:
8180
# build claims
8281
if optional_claims is not None:
@@ -88,7 +87,7 @@ def buildJWT(
8887
claims["iat"] = int(iat.timestamp())
8988
if exp is not None:
9089
claims["exp"] = int(exp.timestamp())
91-
encoded_list = self.list.encode(mtime=mtime)
90+
encoded_list = self.list.encode()
9291
claims["status_list"] = {
9392
"bits": self.list.bits,
9493
"lst": encoded_list,

0 commit comments

Comments
 (0)