zaikio-oauth_client 0.3.7 → 0.4.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb774c96ee88f324e6da5b8ece141a110f306d5a38506ab33bb1c44b4fa6ca16
|
4
|
+
data.tar.gz: 6bf71d03fac23bca3c96fe38c7b7ad84d0f609dc98a4cc673ab44e83dfff001f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 878a92cd495fb07fa942a0e100862586a42c262bafdd9afa64d9cee76efd2b3a85d833b4c92bda916f66afa97c6c7cfe9090ddee2cdf9834a7deae3c22bb0bc3
|
7
|
+
data.tar.gz: 72084e3c353aeed81b6dbc7cee0eb2ae44ab5140c5a55319dc4933e35944881d66a98fa329230d3a3b902e98701f1dc9de6e05539e9b1f8917720c5056f21a3c
|
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
|
@@ -210,7 +234,7 @@ If you use the provided OAuth credentials from above and test this against the S
|
|
210
234
|
|
211
235
|
**Make sure you have the dummy app running locally to validate your changes.**
|
212
236
|
|
213
|
-
Make your changes and adjust `version.rb`.
|
237
|
+
Make your changes and adjust `version.rb`. Please make sure to update `CHANGELOG.md`.
|
214
238
|
|
215
239
|
**To push a new release:**
|
216
240
|
|
@@ -26,21 +26,24 @@ module Zaikio
|
|
26
26
|
# Scopes
|
27
27
|
scope :valid, lambda {
|
28
28
|
where("expires_at > :now", now: Time.current)
|
29
|
-
.where.not(id: Zaikio::JWTAuth.
|
29
|
+
.where.not(id: Zaikio::JWTAuth.revoked_token_ids)
|
30
|
+
}
|
31
|
+
scope :with_invalid_refresh_token, lambda {
|
32
|
+
where("created_at <= ?", Time.current - Zaikio::AccessToken.refresh_token_valid_for)
|
30
33
|
}
|
31
34
|
scope :valid_refresh, lambda {
|
32
35
|
where("expires_at <= :now AND created_at > :created_at_max",
|
33
36
|
now: Time.current,
|
34
37
|
created_at_max: Time.current - refresh_token_valid_for)
|
35
38
|
.where("refresh_token IS NOT NULL")
|
36
|
-
.where.not(id: Zaikio::JWTAuth.
|
39
|
+
.where.not(id: Zaikio::JWTAuth.revoked_token_ids)
|
37
40
|
}
|
38
41
|
scope :by_bearer, lambda { |bearer_type: "Person", bearer_id:, scopes: []|
|
39
42
|
where(bearer_type: bearer_type, bearer_id: bearer_id)
|
40
43
|
.where("scopes @> ARRAY[?]::varchar[]", scopes)
|
41
44
|
}
|
42
45
|
scope :usable, lambda { |options|
|
43
|
-
by_bearer(options).valid.or(by_bearer(options).valid_refresh)
|
46
|
+
by_bearer(**options).valid.or(by_bearer(**options).valid_refresh)
|
44
47
|
.order(expires_at: :desc)
|
45
48
|
}
|
46
49
|
|
@@ -5,11 +5,11 @@ module Zaikio
|
|
5
5
|
module OAuthClient
|
6
6
|
class Configuration
|
7
7
|
HOSTS = {
|
8
|
-
development: "http://
|
9
|
-
test: "http://
|
10
|
-
staging: "https://
|
11
|
-
sandbox: "https://
|
12
|
-
production: "https://
|
8
|
+
development: "http://hub.zaikio.test",
|
9
|
+
test: "http://hub.zaikio.test",
|
10
|
+
staging: "https://hub.staging.zaikio.com",
|
11
|
+
sandbox: "https://hub.sandbox.zaikio.com",
|
12
|
+
production: "https://hub.zaikio.com"
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
attr_accessor :host
|
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.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zaikio GmbH
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-13 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.5.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.5.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
|
@@ -112,11 +119,12 @@ files:
|
|
112
119
|
- lib/zaikio/oauth_client/engine.rb
|
113
120
|
- lib/zaikio/oauth_client/test_helper.rb
|
114
121
|
- lib/zaikio/oauth_client/version.rb
|
115
|
-
homepage: https://
|
122
|
+
homepage: https://www.zaikio.com
|
116
123
|
licenses:
|
117
124
|
- MIT
|
118
|
-
metadata:
|
119
|
-
|
125
|
+
metadata:
|
126
|
+
changelog_uri: https://github.com/zaikio/zaikio-oauth_client/blob/master/CHANGELOG.md
|
127
|
+
post_install_message:
|
120
128
|
rdoc_options: []
|
121
129
|
require_paths:
|
122
130
|
- lib
|
@@ -131,8 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
139
|
- !ruby/object:Gem::Version
|
132
140
|
version: '0'
|
133
141
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
135
|
-
signing_key:
|
142
|
+
rubygems_version: 3.2.3
|
143
|
+
signing_key:
|
136
144
|
specification_version: 4
|
137
145
|
summary: Zaikio Platform Connectivity
|
138
146
|
test_files: []
|