token_checksum 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/token_checksum/version.rb +1 -1
- data/lib/token_checksum.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35778c0c9930ef13a6ac8031d9e062ba7743448ecbd41688fc4d23285c28090e
|
4
|
+
data.tar.gz: 136963fe3894f9fd3aab73329ed6156404ef656551083706c7dc30ef59b1d616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87107d68ddbcc35b987ca39b76e369932bb5b670d56f7638773d6770432eb4a0cd55e39c6e6c7644939c0661de7489b0d18fd9335a9fb4349f822898d75645d9
|
7
|
+
data.tar.gz: f93b72fdd81da6fb06aac30fefe81c9192e125725ce0b9d23878d328e53872067986cfe6144ac85d5e34907c0aa5956c25aff622af2c635cffb0f22d4e01be6a
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TokenChecksum
|
2
2
|
|
3
|
-
Generates a
|
3
|
+
Generates a 30 character long random token, with a prefix and a 32-bit checksum in the last 6 digits. Inspired by:
|
4
4
|
|
5
5
|
* https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
|
6
6
|
* https://github.com/stefansundin/token-checksum
|
data/lib/token_checksum.rb
CHANGED
@@ -12,6 +12,8 @@ if ENV.fetch("DEBUG", "false")
|
|
12
12
|
end
|
13
13
|
|
14
14
|
module TokenChecksum
|
15
|
+
REGEX = /([abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{1,})_([0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{30})([0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]{6})/
|
16
|
+
|
15
17
|
class << self
|
16
18
|
def generate(prefix, secret: "")
|
17
19
|
suffix = (random_base62 + random_base62)[0...30]
|
@@ -41,7 +43,7 @@ module TokenChecksum
|
|
41
43
|
end
|
42
44
|
|
43
45
|
private def random_base62
|
44
|
-
Base62.encode(SecureRandom.uuid.delete("-").
|
46
|
+
Base62.encode(SecureRandom.uuid.delete("-").to_i(16))
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: token_checksum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: securecompare
|