minato-rails-auth 0.2.1 → 0.2.3
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/.rubocop.yml +1 -1
- data/lib/minato/rails/auth/jwt/spec/contexts.rb +14 -3
- data/lib/minato/rails/auth/user.rb +41 -10
- data/lib/minato/rails/auth/version.rb +1 -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: fd68460698a1370828ff45e5bb4836b116a7ad009117442d7648106819ce9020
|
4
|
+
data.tar.gz: bf643b4c8cd5caaec81f0d65ce9e1a65ae33bfdf5809fe600c8cd1ded02f7126
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bac1061d4313611d88bee29320c440eb61c33b0e99f7e87923fd5d8b994a5a60df269d010f774af338250047ebe95d408b744560d1e0be5065638e7854e0798
|
7
|
+
data.tar.gz: 3ff04da825379e2ec3e07f258059651970ba89a1dd956dc27b0edefa5869098f5ded116ee6153f776b996f7ff242f3181090b4875190321b3e0f4e6e89168f69
|
data/.rubocop.yml
CHANGED
@@ -20,12 +20,23 @@ module Minato
|
|
20
20
|
let(:jwt_account_id) { '555' }
|
21
21
|
let(:jwt_session_id) { '67cf621f-4f49-4ca5-9365-62520849170b' }
|
22
22
|
let(:jwt_identity_id) { 'adb1e688-17c0-4241-bc24-912fa6b5f6c3' }
|
23
|
+
let(:jwt_authentication_method) { 'password' }
|
24
|
+
let(:jwt_authentication_provider) { '' }
|
25
|
+
let(:jwt_authentication_methods) do
|
26
|
+
[
|
27
|
+
{
|
28
|
+
'method' => jwt_authentication_method,
|
29
|
+
'provider' => jwt_authentication_provider
|
30
|
+
}
|
31
|
+
]
|
32
|
+
end
|
23
33
|
let(:jwt_payload) do
|
24
34
|
{
|
25
35
|
'session' => {
|
26
|
-
'id'
|
27
|
-
'expires_at'
|
28
|
-
'
|
36
|
+
'id' => jwt_session_id,
|
37
|
+
'expires_at' => '2021-09-29T20:15:44.731576Z',
|
38
|
+
'authentication_methods' => jwt_authentication_methods,
|
39
|
+
'identity' => {
|
29
40
|
'id' => jwt_identity_id,
|
30
41
|
'traits' => {
|
31
42
|
'email' => jwt_email
|
@@ -6,42 +6,73 @@ module Minato
|
|
6
6
|
module Rails
|
7
7
|
module Auth
|
8
8
|
class User
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :token_payload_obj, :token_payload_raw
|
10
10
|
|
11
11
|
def initialize(token_payload)
|
12
|
-
@
|
12
|
+
@token_payload_raw = token_payload
|
13
|
+
@token_payload_obj = ObjectHash.new(token_payload)
|
13
14
|
end
|
14
15
|
|
15
16
|
def human?
|
16
|
-
|
17
|
+
session_obj&.identity.present?
|
17
18
|
end
|
18
19
|
|
19
20
|
def machine?
|
20
|
-
|
21
|
+
!human?
|
22
|
+
end
|
23
|
+
|
24
|
+
def auth_sso?
|
25
|
+
authentication_method? 'oidc'
|
26
|
+
end
|
27
|
+
|
28
|
+
def auth_password?
|
29
|
+
authentication_method? 'password'
|
30
|
+
end
|
31
|
+
|
32
|
+
def auth_provider
|
33
|
+
return unless auth_sso?
|
34
|
+
|
35
|
+
authentication_method('oidc')['provider']
|
21
36
|
end
|
22
37
|
|
23
38
|
def identity
|
39
|
+
return nil if machine?
|
40
|
+
|
24
41
|
return impersonator_identity unless impersonated?
|
25
42
|
|
26
|
-
|
43
|
+
session_obj.identity.metadata_public.impersonated_identity
|
27
44
|
end
|
28
45
|
|
29
46
|
def impersonator_identity
|
30
|
-
|
47
|
+
session_obj.identity
|
31
48
|
end
|
32
49
|
|
33
50
|
def subject
|
34
|
-
@
|
51
|
+
@token_payload_obj.sub
|
35
52
|
end
|
36
53
|
|
37
54
|
def impersonated?
|
38
|
-
|
55
|
+
return false if machine?
|
56
|
+
|
57
|
+
session_obj.identity.metadata_public&.impersonated_identity.present?
|
39
58
|
end
|
40
59
|
|
41
60
|
private
|
42
61
|
|
43
|
-
def
|
44
|
-
@
|
62
|
+
def session_obj
|
63
|
+
@token_payload_obj.session
|
64
|
+
end
|
65
|
+
|
66
|
+
def session_raw
|
67
|
+
@token_payload_raw['session']
|
68
|
+
end
|
69
|
+
|
70
|
+
def authentication_method(auth_method)
|
71
|
+
session_raw['authentication_methods']&.find { |m| m['method'].to_s == auth_method.to_s }
|
72
|
+
end
|
73
|
+
|
74
|
+
def authentication_method?(auth_method)
|
75
|
+
authentication_method(auth_method).present?
|
45
76
|
end
|
46
77
|
end
|
47
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minato-rails-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|