veri 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +7 -0
- data/lib/veri/configuration.rb +1 -2
- data/lib/veri/controllers/concerns/authentication.rb +5 -6
- data/lib/veri/inputs/hashing_algorithm.rb +1 -4
- data/lib/veri/models/session.rb +14 -1
- data/lib/veri/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1d4ce50f8dee062c8b115095760ba5c2ef1e4f6a75db253a12fbb872583b5491
|
|
4
|
+
data.tar.gz: 20948f1a5cfbfb8054b2fb66491d9babae554197487b1369f99f7b5e5d8a213c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f49a78fc5ccba47ece10a67a2b651173ea28000a9aa43b886c514d74334c1273e59b77d07893590014b639b42f324636c025288f5e4a6657c932f222140fb258
|
|
7
|
+
data.tar.gz: 8a3ab38f067b650708e4c0a13af58dbac9ac60fcca30b038c4fbd8a12c6851d55502a5f9033d886d9a345cbe7f06e34bced6160f4d812b8b9bef7792de707e75
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -31,6 +31,7 @@ Consider a multi-tenant SaaS application where users need to manage their active
|
|
|
31
31
|
- [Getting Help and Contributing](#getting-help-and-contributing)
|
|
32
32
|
- [License](#license)
|
|
33
33
|
- [Code of Conduct](#code-of-conduct)
|
|
34
|
+
- [Old Versions](#old-versions)
|
|
34
35
|
|
|
35
36
|
## Installation
|
|
36
37
|
|
|
@@ -509,3 +510,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
|
509
510
|
## Code of Conduct
|
|
510
511
|
|
|
511
512
|
Everyone interacting in the Veri project is expected to follow the [code of conduct](https://github.com/enjaku4/veri/blob/main/CODE_OF_CONDUCT.md).
|
|
513
|
+
|
|
514
|
+
## Old Versions
|
|
515
|
+
|
|
516
|
+
Only the latest major version is supported. Older versions are obsolete and not maintained, but their READMEs are available here for reference:
|
|
517
|
+
|
|
518
|
+
[v1.x.x](https://github.com/enjaku4/veri/blob/9c188e16a703141b7cd89dd31d5cd49a557f143d/README.md)
|
data/lib/veri/configuration.rb
CHANGED
|
@@ -17,7 +17,6 @@ module Veri
|
|
|
17
17
|
pbkdf2: Veri::Password::Pbkdf2,
|
|
18
18
|
scrypt: Veri::Password::SCrypt
|
|
19
19
|
}.freeze
|
|
20
|
-
private_constant :HASHERS
|
|
21
20
|
|
|
22
21
|
def hashing_algorithm=(value)
|
|
23
22
|
@hashing_algorithm = Veri::Inputs::HashingAlgorithm.new(
|
|
@@ -60,7 +59,7 @@ module Veri
|
|
|
60
59
|
end
|
|
61
60
|
|
|
62
61
|
def hasher
|
|
63
|
-
HASHERS.fetch(hashing_algorithm)
|
|
62
|
+
HASHERS.fetch(hashing_algorithm)
|
|
64
63
|
end
|
|
65
64
|
|
|
66
65
|
def user_model
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "zlib"
|
|
2
2
|
|
|
3
3
|
module Veri
|
|
4
4
|
module Authentication
|
|
@@ -25,14 +25,13 @@ module Veri
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def current_user
|
|
28
|
-
|
|
29
|
-
primary_key = user_model.primary_key
|
|
30
|
-
@current_user ||= current_session ? user_model.find_by(primary_key => current_session.authenticatable_id) : nil
|
|
28
|
+
@current_user ||= current_session&.authenticatable
|
|
31
29
|
end
|
|
32
30
|
|
|
33
31
|
def current_session
|
|
34
32
|
token = cookies.encrypted["#{auth_cookie_prefix}_token"]
|
|
35
|
-
|
|
33
|
+
|
|
34
|
+
@current_session ||= Session.lookup(token, resolved_tenant)
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
def log_in(authenticatable)
|
|
@@ -102,7 +101,7 @@ module Veri
|
|
|
102
101
|
end
|
|
103
102
|
|
|
104
103
|
def auth_cookie_prefix
|
|
105
|
-
@auth_cookie_prefix ||= "auth_#{
|
|
104
|
+
@auth_cookie_prefix ||= "auth_#{Zlib.crc32(Marshal.dump(resolved_tenant))}"
|
|
106
105
|
end
|
|
107
106
|
end
|
|
108
107
|
end
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
module Veri
|
|
2
2
|
module Inputs
|
|
3
3
|
class HashingAlgorithm < Veri::Inputs::Base
|
|
4
|
-
HASHING_ALGORITHMS = [:argon2, :bcrypt, :pbkdf2, :scrypt].freeze
|
|
5
|
-
private_constant :HASHING_ALGORITHMS
|
|
6
|
-
|
|
7
4
|
private
|
|
8
5
|
|
|
9
|
-
def processor = -> {
|
|
6
|
+
def processor = -> { Veri::Configuration::HASHERS.key?(@value) ? @value : raise_error }
|
|
10
7
|
end
|
|
11
8
|
end
|
|
12
9
|
end
|
data/lib/veri/models/session.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "digest"
|
|
1
2
|
require "user_agent_parser"
|
|
2
3
|
|
|
3
4
|
module Veri
|
|
@@ -106,7 +107,7 @@ module Veri
|
|
|
106
107
|
expires_at = Time.current + Veri::Configuration.total_session_lifetime
|
|
107
108
|
|
|
108
109
|
new(
|
|
109
|
-
hashed_token:
|
|
110
|
+
hashed_token: digest_token(token),
|
|
110
111
|
expires_at:,
|
|
111
112
|
authenticatable: user,
|
|
112
113
|
**resolved_tenant
|
|
@@ -126,6 +127,18 @@ module Veri
|
|
|
126
127
|
end
|
|
127
128
|
|
|
128
129
|
alias terminate_all delete_all
|
|
130
|
+
|
|
131
|
+
def lookup(token, resolved_tenant)
|
|
132
|
+
return nil if token.blank?
|
|
133
|
+
|
|
134
|
+
find_by(hashed_token: digest_token(token), **resolved_tenant)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
private
|
|
138
|
+
|
|
139
|
+
def digest_token(token)
|
|
140
|
+
Digest::SHA256.hexdigest(token)
|
|
141
|
+
end
|
|
129
142
|
end
|
|
130
143
|
|
|
131
144
|
private
|
data/lib/veri/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: veri
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- enjaku4
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-02-04 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: argon2
|
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
147
147
|
- !ruby/object:Gem::Version
|
|
148
148
|
version: '0'
|
|
149
149
|
requirements: []
|
|
150
|
-
rubygems_version:
|
|
150
|
+
rubygems_version: 3.6.9
|
|
151
151
|
specification_version: 4
|
|
152
152
|
summary: Minimal cookie-based authentication library for Ruby on Rails
|
|
153
153
|
test_files: []
|