zaikio-oauth_client 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70df4bc301aecf7787f230307e05d94a5df5e68bc53c631bd4923e007f1c4882
4
- data.tar.gz: e19b1250fed256fd761c47b08d7b436311547559834b6939202d0bf2b4d35f92
3
+ metadata.gz: 8fa2e5f7ed7f309196e150d97aeabd9bf9480fc9d434a97df1bd3f24c12ea10f
4
+ data.tar.gz: acabd48829a55be6e5f358ff62136cdee973dd2e3e71fb17af4f3dff1b0bf9e9
5
5
  SHA512:
6
- metadata.gz: 621cbc8f24b5db20feebc5398cba2a444cab5a2d9652e44ed53675b889b7033df68410302885781aa7714626ed3f325384e9f6ca80fd21025b2490f6310d4060
7
- data.tar.gz: 728955826c11c5f9d955ad03f1d2c3d9631f023d07aa84fbe9f06583392fb87a9d5850e3195381100aacf4262d94dec725018e3aa9783e862a5a546486aa7ae5
6
+ metadata.gz: 4a6fc57330881a9c13164aedf78bb9138f7baa6b8a062e17ff674ada1527e291314177c65fc81eb02e4a563d29c7f8c8018854ef9613545666a07bbecd793057
7
+ data.tar.gz: ffda5ec35029860201e0c42b50c2dc303f78f9b5e726c19282dd2f023c684516cb3f2ea6a5c092b359b9e8f6c3a03a5d5d91226e0170760ca288752368ac89c3
data/README.md CHANGED
@@ -26,6 +26,8 @@ This will create the tables:
26
26
 
27
27
  ### 2. Mount routes
28
28
 
29
+ Add this to `config/routes.rb`:
30
+
29
31
  ```rb
30
32
  mount Zaikio::OAuthClient::Engine => "/zaikio"
31
33
  ```
@@ -65,6 +67,28 @@ Zaikio::OAuthClient.configure do |config|
65
67
  end
66
68
  ```
67
69
 
70
+
71
+ ### 4. Clean up outdated access tokens (recommended)
72
+
73
+ To avoid keeping all expired oath and refresh tokens in your database, we recommend to implement their scheduled deletion. We recommend therefore to use a schedule gems such as [sidekiq](https://github.com/mperham/sidekiq) and [sidekiq-scheduler](https://github.com/moove-it/sidekiq-scheduler).
74
+
75
+ Simply add the following to your Gemfile:
76
+
77
+ ```rb
78
+ gem "sidekiq"
79
+ gem "sidekiq-scheduler"
80
+ ```
81
+ Then run `bundle install`.
82
+
83
+ Configure sidekiq scheduler in `config/sidekiq.yml`:
84
+ ```yaml
85
+ :schedule:
86
+ cleanup_acces_tokens_job:
87
+ cron: '0 3 * * *' # This will delete all expired tokens every day at 3am.
88
+ class: 'Zaikio::CleanupAccessTokensJob'
89
+ ```
90
+
91
+
68
92
  ## Usage
69
93
 
70
94
  ### OAuth Flow
@@ -0,0 +1,7 @@
1
+ module Zaikio
2
+ class CleanupAccessTokensJob < ApplicationJob
3
+ def perform
4
+ Zaikio::AccessToken.with_invalid_refresh_token.delete_all
5
+ end
6
+ end
7
+ end
@@ -28,6 +28,9 @@ module Zaikio
28
28
  where("expires_at > :now", now: Time.current)
29
29
  .where.not(id: Zaikio::JWTAuth.blacklisted_token_ids)
30
30
  }
31
+ scope :with_invalid_refresh_token, lambda {
32
+ where("created_at <= ?", Time.current - Zaikio::AccessToken.refresh_token_valid_for)
33
+ }
31
34
  scope :valid_refresh, lambda {
32
35
  where("expires_at <= :now AND created_at > :created_at_max",
33
36
  now: Time.current,
@@ -5,11 +5,11 @@ module Zaikio
5
5
  module OAuthClient
6
6
  class Configuration
7
7
  HOSTS = {
8
- development: "http://directory.zaikio.test",
9
- test: "http://directory.zaikio.test",
8
+ development: "http://hub.zaikio.test",
9
+ test: "http://hub.zaikio.test",
10
10
  staging: "https://directory.staging.zaikio.com",
11
11
  sandbox: "https://directory.sandbox.zaikio.com",
12
- production: "https://directory.zaikio.com"
12
+ production: "https://hub.zaikio.com"
13
13
  }.freeze
14
14
 
15
15
  attr_accessor :host
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.3.7".freeze
3
+ VERSION = "0.3.8".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-oauth_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -42,16 +42,22 @@ dependencies:
42
42
  name: zaikio-jwt_auth
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.2.1
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.4.0
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: 0.2.1
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.4.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: pg
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -98,6 +104,7 @@ files:
98
104
  - app/controllers/zaikio/oauth_client/sessions_controller.rb
99
105
  - app/helpers/zaikio/application_helper.rb
100
106
  - app/jobs/zaikio/application_job.rb
107
+ - app/jobs/zaikio/cleanup_access_tokens_job.rb
101
108
  - app/models/zaikio/access_token.rb
102
109
  - config/initializers/inflections.rb
103
110
  - config/locales/en.yml