arkaan 3.2.0 → 3.2.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/lib/arkaan/authentication.rb +1 -0
- data/lib/arkaan/authentication/device.rb +23 -0
- data/lib/arkaan/authentication/session.rb +16 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18e96a942919336b990db83ea8071e368ee4ec191fba5847d9749511160d26cb
|
4
|
+
data.tar.gz: 55c2514a2354be9d8367b2ed93dcc98d2de20da915cdfbc5fb7e22ab53498136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec3fe52c446ca4329b6663662e29e96400d7491c57dfc623fba608be609c4d3f22fc1933f0bfea9518c3b8e226c37093983929d6c4976a81620f1b76bdb2015
|
7
|
+
data.tar.gz: 96a45e10abd6016ee406ad035d9ede8eb75810d220c28f4b7ceef59aeec842947f1bd8ad25b632c8550154ce523a07be1900d5aa3d04afb4c67fa78e64d4144f
|
@@ -4,6 +4,7 @@ module Arkaan
|
|
4
4
|
# This module holds the logic for user authentication to our frontend.
|
5
5
|
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
6
6
|
module Authentication
|
7
|
+
autoload :Device, 'arkaan/authentication/device'
|
7
8
|
autoload :Session, 'arkaan/authentication/session'
|
8
9
|
end
|
9
10
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Arkaan
|
4
|
+
module Authentication
|
5
|
+
# A device is a computer or mobile phone from which a user logs in.
|
6
|
+
# @pauthor Vincent Courtois <courtois.vincent@outlook.com>
|
7
|
+
class Device
|
8
|
+
include Mongoid::Document
|
9
|
+
include Mongoid::Timestamps
|
10
|
+
|
11
|
+
# @!attribute [rw] user_agent
|
12
|
+
# @return [String] the string representation of the browser and OS of the user
|
13
|
+
field :user_agent, type: String
|
14
|
+
# @!attribute [rw] ip
|
15
|
+
# @return [String] the IP address of the user
|
16
|
+
field :ip, type: String
|
17
|
+
|
18
|
+
# @!attribute [rw] sessions
|
19
|
+
# @return [Array<Arkaan::Authentication::Session] the sessions this browser is linked to.
|
20
|
+
has_many :sessions, class_name: 'Arkaan::Authentication::Session', inverse_of: :device
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -17,15 +17,31 @@ module Arkaan
|
|
17
17
|
# @return [String] the ID of the websocket the user is connected to.
|
18
18
|
# It's not an association because instances are embedded.
|
19
19
|
field :websocket_id, type: String, default: ''
|
20
|
+
# @!attribute [rw] duration
|
21
|
+
# @return [Integer] the duration of the session in seconds before it expires.
|
22
|
+
field :duration, type: Integer, default: 86_400
|
20
23
|
|
21
24
|
# @!attribute [rw] account
|
22
25
|
# @return [Arkaan::Account] the account connected to the application.
|
23
26
|
belongs_to :account, class_name: 'Arkaan::Account', inverse_of: :sessions
|
27
|
+
# @!attribute [rw] device
|
28
|
+
# @return [Arkaan::Authentication::Device] the device (computer/mobile) linked to this session
|
29
|
+
belongs_to :device, class_name: 'Arkaan::Authentication::Session', inverse_of: :sessions, optional: true
|
24
30
|
|
25
31
|
validates :session_id,
|
26
32
|
presence: { message: 'required' },
|
27
33
|
uniqueness: { message: 'uniq', if: :session_id? },
|
28
34
|
length: { minimum: 10, message: 'minlength', if: :session_id? }
|
35
|
+
|
36
|
+
validates :duration,
|
37
|
+
numericality: { greater_than_or_equal_to: 0, message: 'minimum' },
|
38
|
+
presence: { message: 'required' }
|
39
|
+
|
40
|
+
# Checks if the session is expired (it has a duration, and the duration has passed)
|
41
|
+
# @return [Boolean] TRUE if the session is expired, FALSE otherwise.
|
42
|
+
def expired?
|
43
|
+
duration != 0 && created_at + duration.to_f < DateTime.now
|
44
|
+
end
|
29
45
|
end
|
30
46
|
end
|
31
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_cleaner
|
@@ -313,6 +313,7 @@ files:
|
|
313
313
|
- lib/arkaan.rb
|
314
314
|
- lib/arkaan/account.rb
|
315
315
|
- lib/arkaan/authentication.rb
|
316
|
+
- lib/arkaan/authentication/device.rb
|
316
317
|
- lib/arkaan/authentication/session.rb
|
317
318
|
- lib/arkaan/campaign.rb
|
318
319
|
- lib/arkaan/campaigns.rb
|