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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17672738e498e3328b8b4cf724e3b30e4ee3fb2f7c1d768344cd0c9d29ced1df
4
- data.tar.gz: bb8031eb131fce46b349e6881d8b20a18d43c19bf4aba7b41ae1bc6474e5c3cd
3
+ metadata.gz: 5059569cdd9359f72eb4852779102dca282a75176073020888ecfffb6ac716c0
4
+ data.tar.gz: ee0b24a4e5a9f105f10c6cb7cb550f90449a87031622577cc89211edac5bb06d
5
5
  SHA512:
6
- metadata.gz: a6000202fed29f8e3e303d831727c7199cc073dcec3c592e412b3234b3a55c06b5761f4781f7325d7113a44af2c2f4786fff526b7d9bbd30eaebf599e62987e0
7
- data.tar.gz: eaa49fd164b25daefeb97c505d73b11fb148f433f940594a6e6a349eae8a341f3ad8a716eccd5e47204968685602c895185ee255144cf39680eab610d66e83c1
6
+ metadata.gz: '0910cd4e2a58796521a755ed2e6414d647270ce94582c2247574f2189e2949d5cb9297f0cbda06414586f845bb00a484974a2752e079de7906c770cd153afd20'
7
+ data.tar.gz: 6bf989a229323abf6160b91bded464993f8606810d5883a40d32eb7e6e66c0bb4742cae90cf5246b1848f2b20a9014d66cf0867dea20de1dc10dbe297f1e1c5e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v1.1.0
2
+
3
+ ### Features
4
+
5
+ - Added `Veri::Session.in_tenant` method to fetch sessions for a specific tenant
6
+
7
+ ### Misc
8
+
9
+ - Added support for Rails 8.1
10
+
1
11
  ## v1.0.1
2
12
 
3
13
  ### Bugs
data/README.md CHANGED
@@ -5,17 +5,11 @@
5
5
  [![Github Actions badge](https://github.com/enjaku4/veri/actions/workflows/ci.yml/badge.svg)](https://github.com/enjaku4/veri/actions/workflows/ci.yml)
6
6
  [![License](https://img.shields.io/github/license/enjaku4/veri.svg)](LICENSE)
7
7
 
8
- Veri is a cookie-based authentication library for Ruby on Rails. Unlike other solutions, Veri doesn't impose business logic or generate controllers, views, and mailers for you. Instead, it provides essential authentication building blocks giving you complete control over your authentication flow while handling the complex underlying mechanics of secure password storage and session management.
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
- **Key Features:**
10
+ **Example of Usage:**
11
11
 
12
- - Cookie-based authentication with database-stored sessions
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 unauthenticated
216
+ ### When Unauthenticated
223
217
 
224
- Override this private method to customize unauthenticated user behavior:
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're treated as unauthenticated.
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 like organizations, clients, or subdomains.
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.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Veri
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.1.0".freeze
3
3
  end
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.1"
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.1
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.1'
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.1'
87
+ version: '8.2'
88
88
  - !ruby/object:Gem::Dependency
89
89
  name: scrypt
90
90
  requirement: !ruby/object:Gem::Requirement