authkeeper 0.1.5 → 0.1.7
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/app/lib/authkeeper/jwt_encoder.rb +7 -2
- data/app/lib/authkeeper/vk_auth_api/client.rb +1 -1
- data/app/lib/authkeeper/vk_auth_api/requests/{fetch_access_token.rb → access_token.rb} +17 -1
- data/app/services/authkeeper/providers/vk.rb +2 -2
- data/lib/authkeeper/configuration.rb +3 -0
- data/lib/authkeeper/version.rb +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: 4df1a975a6ed32b2e3c7a1c7371796e8112db93c7fe74cac15a7aaf7bb8d3d21
|
4
|
+
data.tar.gz: 65d219ac4b2d153c3846dd4c70a9cacb5798ba6c41b2aea76ab9e749c61138e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb12a72dbace108366d05d6051183dbe651bbc0e92eb5d8365bdec4f5e5d1b23b110cf8c3c9880e4ea1415be7a7331241f1bd7fef776197c811196852ae79e0e
|
7
|
+
data.tar.gz: d9db1df5121f1c583f94a74c97915038bc0ae3154a775adb7e8abe11649134bc9951ada4b975d50a91a65aacb944f1eb1e93e25eeb3bfd06dc24a89041fdf680
|
@@ -3,7 +3,6 @@
|
|
3
3
|
module Authkeeper
|
4
4
|
class JwtEncoder
|
5
5
|
HMAC_SECRET = Rails.application.secret_key_base
|
6
|
-
EXPIRATION_SECONDS = 604_800 # 1.week
|
7
6
|
|
8
7
|
def encode(payload:, secret: HMAC_SECRET)
|
9
8
|
JWT.encode(modify_payload(payload), secret)
|
@@ -18,8 +17,14 @@ module Authkeeper
|
|
18
17
|
def modify_payload(payload)
|
19
18
|
payload.merge!(
|
20
19
|
random: SecureRandom.hex,
|
21
|
-
exp: DateTime.now.to_i +
|
20
|
+
exp: DateTime.now.to_i + token_expiration_seconds
|
22
21
|
)
|
23
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def token_expiration_seconds
|
27
|
+
@token_expiration_seconds ||= Authkeeper.configuration.token_expiration_seconds
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
module Authkeeper
|
6
6
|
module VkAuthApi
|
7
7
|
module Requests
|
8
|
-
module
|
8
|
+
module AccessToken
|
9
9
|
def fetch_access_token(client_id:, redirect_url:, device_id:, code:, state:, code_verifier:)
|
10
10
|
post(
|
11
11
|
path: 'oauth2/auth',
|
@@ -23,6 +23,22 @@ module Authkeeper
|
|
23
23
|
}
|
24
24
|
)
|
25
25
|
end
|
26
|
+
|
27
|
+
def refresh_access_token(client_id:, refresh_token:, device_id:, state:)
|
28
|
+
post(
|
29
|
+
path: 'oauth2/auth',
|
30
|
+
body: URI.encode_www_form({
|
31
|
+
grant_type: 'refresh_token',
|
32
|
+
client_id: client_id,
|
33
|
+
device_id: device_id,
|
34
|
+
refresh_token: refresh_token,
|
35
|
+
state: state
|
36
|
+
}),
|
37
|
+
headers: {
|
38
|
+
'Content-Type' => 'application/x-www-form-urlencoded'
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
26
42
|
end
|
27
43
|
end
|
28
44
|
end
|
@@ -17,7 +17,7 @@ module Authkeeper
|
|
17
17
|
# "expires_in" => 3600,
|
18
18
|
# "user_id" => 176780000,
|
19
19
|
# "state" => "ce4a09792e2cc8065a96074906709765",
|
20
|
-
# "scope" => "vkid.personal_info email"
|
20
|
+
# "scope" => "vkid.personal_info email phone ads"
|
21
21
|
# }
|
22
22
|
|
23
23
|
user_info = fetch_user_info(auth_info['access_token'])
|
@@ -36,7 +36,7 @@ module Authkeeper
|
|
36
36
|
|
37
37
|
{
|
38
38
|
result: {
|
39
|
-
auth_info: auth_info.symbolize_keys,
|
39
|
+
auth_info: auth_info.symbolize_keys.merge(device_id: params[:device_id]),
|
40
40
|
user_info: {
|
41
41
|
uid: user_info.dig('user', 'user_id'),
|
42
42
|
provider: 'vk',
|
@@ -5,6 +5,7 @@ module Authkeeper
|
|
5
5
|
InitializeError = Class.new(StandardError)
|
6
6
|
|
7
7
|
attr_accessor :user_model, :user_session_model, :access_token_name, :domain, :fallback_url_session_name, :omniauth_providers
|
8
|
+
:token_expiration_seconds
|
8
9
|
attr_reader :omniauth_configs
|
9
10
|
|
10
11
|
def initialize
|
@@ -17,6 +18,8 @@ module Authkeeper
|
|
17
18
|
|
18
19
|
@omniauth_providers = []
|
19
20
|
@omniauth_configs = {}
|
21
|
+
|
22
|
+
@token_expiration_seconds = 18_144_000 # 30.days
|
20
23
|
end
|
21
24
|
|
22
25
|
def validate
|
data/lib/authkeeper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdanov Anton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -53,7 +53,7 @@ files:
|
|
53
53
|
- app/lib/authkeeper/google_auth_api/requests/fetch_access_token.rb
|
54
54
|
- app/lib/authkeeper/jwt_encoder.rb
|
55
55
|
- app/lib/authkeeper/vk_auth_api/client.rb
|
56
|
-
- app/lib/authkeeper/vk_auth_api/requests/
|
56
|
+
- app/lib/authkeeper/vk_auth_api/requests/access_token.rb
|
57
57
|
- app/lib/authkeeper/vk_auth_api/requests/info.rb
|
58
58
|
- app/lib/authkeeper/yandex_api/client.rb
|
59
59
|
- app/lib/authkeeper/yandex_api/requests/info.rb
|