compeon-access_token 0.3.0 → 0.4.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/Gemfile.lock +1 -1
- data/lib/compeon/access_token.rb +5 -3
- data/lib/compeon/access_token/version.rb +1 -1
- data/lib/compeon/token/access.rb +8 -3
- data/lib/compeon/token/authorization.rb +8 -3
- data/lib/compeon/token/base.rb +13 -1
- data/lib/compeon/token/encoder.rb +1 -0
- 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: 0cc9d4474834d3d8f14b3de7fba0da4ada1ca28853808405ff2b1af80f7f7886
|
4
|
+
data.tar.gz: 0f02baf6512b4dd6bb0fde8fe481e6a795164827d4bb92c282fdb71b6254c38b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbc7b9b07c6348450b5e3ea2ddf1330b24e5c6f2f6542a02f4c239d950c5cbbeaa717d2dce6fbf337b4ee9c6fd02eccecf6789f2dfa9489fd41e79e0dc6fdf31
|
7
|
+
data.tar.gz: 6c5c5161559225af5c8e61b9861d324ecd41e7f578ea04a77b0ff421a6ca59b9f7a974d5207a8c87bdaac973593edbc9712c18b14922029d5d5cf342026f6d1e
|
data/Gemfile.lock
CHANGED
data/lib/compeon/access_token.rb
CHANGED
@@ -9,15 +9,16 @@ module Compeon
|
|
9
9
|
class AccessToken
|
10
10
|
class ParseError < RuntimeError; end
|
11
11
|
|
12
|
-
def initialize(role:, user_id:, kind:, client_id:, token:)
|
12
|
+
def initialize(role:, user_id:, kind:, client_id:, session_id: nil, token:)
|
13
13
|
@role = role
|
14
14
|
@user_id = user_id
|
15
15
|
@kind = kind
|
16
16
|
@client_id = client_id
|
17
|
+
@session_id = session_id
|
17
18
|
@token = token
|
18
19
|
end
|
19
20
|
|
20
|
-
attr_reader :role, :user_id, :kind, :client_id, :token
|
21
|
+
attr_reader :role, :user_id, :kind, :client_id, :session_id, :token
|
21
22
|
|
22
23
|
class << self
|
23
24
|
attr_writer :environment
|
@@ -35,8 +36,9 @@ module Compeon
|
|
35
36
|
user_id = data.fetch('uid')
|
36
37
|
kind = data.fetch('knd')
|
37
38
|
client_id = data.fetch('cid')
|
39
|
+
session_id = data.fetch('sid')
|
38
40
|
|
39
|
-
new(role: role, user_id: user_id, kind: kind, client_id: client_id, token: token)
|
41
|
+
new(role: role, user_id: user_id, kind: kind, client_id: client_id, session_id: session_id, token: token)
|
40
42
|
rescue JWT::DecodeError
|
41
43
|
raise ParseError
|
42
44
|
end
|
data/lib/compeon/token/access.rb
CHANGED
@@ -4,7 +4,7 @@ module Compeon
|
|
4
4
|
module Token
|
5
5
|
class Access < Base
|
6
6
|
class << self
|
7
|
-
def
|
7
|
+
def required_attributes_mapping
|
8
8
|
{
|
9
9
|
client_id: :cid,
|
10
10
|
role: :role,
|
@@ -12,6 +12,10 @@ module Compeon
|
|
12
12
|
}.freeze
|
13
13
|
end
|
14
14
|
|
15
|
+
def optional_attributes_mapping
|
16
|
+
{ session_id: :sid }.freeze
|
17
|
+
end
|
18
|
+
|
15
19
|
def jwt_algorithm
|
16
20
|
'RS256'
|
17
21
|
end
|
@@ -21,13 +25,14 @@ module Compeon
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
attr_accessor :client_id, :role, :user_id
|
28
|
+
attr_accessor :client_id, :role, :user_id, :session_id
|
25
29
|
|
26
|
-
def initialize(client_id:, role:, user_id:, **claims)
|
30
|
+
def initialize(client_id:, role:, user_id:, session_id: nil, **claims)
|
27
31
|
super(claims)
|
28
32
|
@client_id = client_id
|
29
33
|
@role = role
|
30
34
|
@user_id = user_id
|
35
|
+
@session_id = session_id
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
@@ -4,7 +4,7 @@ module Compeon
|
|
4
4
|
module Token
|
5
5
|
class Authorization < Base
|
6
6
|
class << self
|
7
|
-
def
|
7
|
+
def required_attributes_mapping
|
8
8
|
{
|
9
9
|
client_id: :cid,
|
10
10
|
redirect_uri: :uri,
|
@@ -12,6 +12,10 @@ module Compeon
|
|
12
12
|
}.freeze
|
13
13
|
end
|
14
14
|
|
15
|
+
def optional_attributes_mapping
|
16
|
+
{ session_id: :sid }.freeze
|
17
|
+
end
|
18
|
+
|
15
19
|
def jwt_algorithm
|
16
20
|
'RS256'
|
17
21
|
end
|
@@ -21,13 +25,14 @@ module Compeon
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
attr_accessor :client_id, :redirect_uri, :user_id
|
28
|
+
attr_accessor :client_id, :redirect_uri, :user_id, :session_id
|
25
29
|
|
26
|
-
def initialize(client_id:, redirect_uri:, user_id:, **claims)
|
30
|
+
def initialize(client_id:, redirect_uri:, user_id:, session_id: nil, **claims)
|
27
31
|
super(claims)
|
28
32
|
@client_id = client_id
|
29
33
|
@redirect_uri = redirect_uri
|
30
34
|
@user_id = user_id
|
35
|
+
@session_id = session_id
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
data/lib/compeon/token/base.rb
CHANGED
@@ -10,6 +10,18 @@ module Compeon
|
|
10
10
|
@attributes ||= attributes_mapping.keys.freeze
|
11
11
|
end
|
12
12
|
|
13
|
+
def attributes_mapping
|
14
|
+
required_attributes_mapping.merge(optional_attributes_mapping).freeze
|
15
|
+
end
|
16
|
+
|
17
|
+
def required_attributes
|
18
|
+
@required_attributes ||= required_attributes_mapping.keys.freeze
|
19
|
+
end
|
20
|
+
|
21
|
+
def optional_attributes
|
22
|
+
@optional_attributes ||= optional_attributes_mapping.keys.freeze
|
23
|
+
end
|
24
|
+
|
13
25
|
def registered_claims_mapping
|
14
26
|
{
|
15
27
|
audience: :aud,
|
@@ -65,7 +77,7 @@ module Compeon
|
|
65
77
|
end
|
66
78
|
|
67
79
|
def attributes_valid?
|
68
|
-
self.class.
|
80
|
+
self.class.required_attributes.none? { |accessor| public_send(accessor).nil? }
|
69
81
|
end
|
70
82
|
end
|
71
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compeon-access_token
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Schilling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|