veri 1.0.1 → 1.1.0
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 +10 -0
- data/README.md +20 -13
- data/lib/veri/models/session.rb +1 -0
- data/lib/veri/version.rb +1 -1
- data/veri.gemspec +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: 5059569cdd9359f72eb4852779102dca282a75176073020888ecfffb6ac716c0
|
4
|
+
data.tar.gz: ee0b24a4e5a9f105f10c6cb7cb550f90449a87031622577cc89211edac5bb06d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0910cd4e2a58796521a755ed2e6414d647270ce94582c2247574f2189e2949d5cb9297f0cbda06414586f845bb00a484974a2752e079de7906c770cd153afd20'
|
7
|
+
data.tar.gz: 6bf989a229323abf6160b91bded464993f8606810d5883a40d32eb7e6e66c0bb4742cae90cf5246b1848f2b20a9014d66cf0867dea20de1dc10dbe297f1e1c5e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,17 +5,11 @@
|
|
5
5
|
[](https://github.com/enjaku4/veri/actions/workflows/ci.yml)
|
6
6
|
[](LICENSE)
|
7
7
|
|
8
|
-
Veri is a cookie-based authentication library for Ruby on Rails. Unlike other solutions
|
8
|
+
Veri is a cookie-based authentication library for Ruby on Rails. Unlike other solutions that generate controllers, views, and mailers for you, Veri provides only essential building blocks. It's ideal for applications that require custom authentication experiences: you design your own interfaces and flows, while Veri handles the complex underlying mechanics of secure password storage and session verification. On top of that, Veri supports multi-tenancy, granular session management, multiple password hashing algorithms, and includes a user impersonation feature.
|
9
9
|
|
10
|
-
**
|
10
|
+
**Example of Usage:**
|
11
11
|
|
12
|
-
|
13
|
-
- Multiple password hashing algorithms (argon2, bcrypt, pbkdf2, scrypt)
|
14
|
-
- Multi-tenancy support
|
15
|
-
- Granular session management and control
|
16
|
-
- User impersonation feature
|
17
|
-
- Account lockout functionality
|
18
|
-
- Return path handling
|
12
|
+
Consider a multi-tenant SaaS application where users can view all their active sessions across devices and browsers and terminate specific sessions remotely. Administrators have the same interface in their admin panel, giving them visibility into user activity and the ability to end sessions or lock accounts for security. Additionally, administrators can temporarily assume a user’s identity for troubleshooting. All of this is easily handled with Veri.
|
19
13
|
|
20
14
|
## Table of Contents
|
21
15
|
|
@@ -219,9 +213,9 @@ Controller helper:
|
|
219
213
|
shapeshifter?
|
220
214
|
```
|
221
215
|
|
222
|
-
### When
|
216
|
+
### When Unauthenticated
|
223
217
|
|
224
|
-
Override this private method to customize unauthenticated
|
218
|
+
Override this private method to customize behavior for unauthenticated users:
|
225
219
|
|
226
220
|
```rb
|
227
221
|
class ApplicationController < ActionController::Base
|
@@ -332,11 +326,11 @@ User.locked
|
|
332
326
|
User.unlocked
|
333
327
|
```
|
334
328
|
|
335
|
-
When an account is locked, the user cannot log in. If they're already logged in, their sessions are terminated and they
|
329
|
+
When an account is locked, the user cannot log in. If they're already logged in, their sessions are terminated and they are treated as unauthenticated.
|
336
330
|
|
337
331
|
## Multi-Tenancy
|
338
332
|
|
339
|
-
Veri supports multi-tenancy, allowing you to isolate authentication sessions between different tenants
|
333
|
+
Veri supports multi-tenancy, allowing you to isolate authentication sessions between different tenants such as organizations, clients, or subdomains.
|
340
334
|
|
341
335
|
### Setting Up Multi-Tenancy
|
342
336
|
|
@@ -369,6 +363,19 @@ Sessions expose their tenant through `tenant` method:
|
|
369
363
|
session.tenant
|
370
364
|
```
|
371
365
|
|
366
|
+
To manage sessions for a specific tenant:
|
367
|
+
|
368
|
+
```rb
|
369
|
+
# Fetch all sessions for a given tenant
|
370
|
+
Veri::Session.in_tenant(tenant)
|
371
|
+
|
372
|
+
# Fetch sessions for a specific user within a tenant
|
373
|
+
user.sessions.in_tenant(tenant)
|
374
|
+
|
375
|
+
# Terminate all sessions for a specific user within a tenant
|
376
|
+
user.sessions.in_tenant(tenant).terminate_all
|
377
|
+
```
|
378
|
+
|
372
379
|
### Migration Helpers
|
373
380
|
|
374
381
|
Handle tenant changes when models are renamed or removed. These are irreversible data migrations.
|
data/lib/veri/models/session.rb
CHANGED
@@ -8,6 +8,7 @@ module Veri
|
|
8
8
|
belongs_to :original_authenticatable, class_name: Veri::Configuration.user_model_name, optional: true
|
9
9
|
belongs_to :tenant, polymorphic: true, optional: true
|
10
10
|
|
11
|
+
scope :in_tenant, -> (tenant) { where(**Veri::Inputs::Tenant.new(tenant).resolve) }
|
11
12
|
scope :active, -> { where.not(id: expired.select(:id)).where.not(id: inactive.select(:id)) }
|
12
13
|
scope :expired, -> { where(expires_at: ...Time.current) }
|
13
14
|
scope :inactive, -> do
|
data/lib/veri/version.rb
CHANGED
data/veri.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency "bcrypt", "~> 3.0"
|
28
28
|
spec.add_dependency "dry-configurable", "~> 1.1"
|
29
29
|
spec.add_dependency "dry-types", "~> 1.7"
|
30
|
-
spec.add_dependency "rails", ">= 7.2", "< 8.
|
30
|
+
spec.add_dependency "rails", ">= 7.2", "< 8.2"
|
31
31
|
spec.add_dependency "scrypt", "~> 3.0"
|
32
32
|
spec.add_dependency "user_agent_parser", "~> 2.0"
|
33
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: veri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- enjaku4
|
@@ -74,7 +74,7 @@ dependencies:
|
|
74
74
|
version: '7.2'
|
75
75
|
- - "<"
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version: '8.
|
77
|
+
version: '8.2'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -84,7 +84,7 @@ dependencies:
|
|
84
84
|
version: '7.2'
|
85
85
|
- - "<"
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '8.
|
87
|
+
version: '8.2'
|
88
88
|
- !ruby/object:Gem::Dependency
|
89
89
|
name: scrypt
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|