oauth_im 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -5
- data/app/controllers/concerns/oauth_im/authenticable.rb +3 -7
- data/config/initializers/app_context.rb +12 -9
- data/lib/oauth_im/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: 8208d820c7e100554ecce30e7059fd4d082679a90875a6345a19cb072c010f2c
|
4
|
+
data.tar.gz: 4210b53980b4d73a75bd4a48ec5318d2369e22e7d3db15253b5d706dd4c46821
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38d9767641f6b8b691cfc1ceaabac18db7bfdade8f04d4110d669c3c5b48f9e0a501931c859650d7976f458225233e97eb475f92b8dcb2ca9b2b66488c596cfc
|
7
|
+
data.tar.gz: 2ed159a29e9164d3aec610e20559a65fe6386e065945b942f7b1dded21a4aac0bc7f38ac2333b2a0a529134273286700dff636a65ba75518ee1586cd677ff0cb
|
data/README.md
CHANGED
@@ -111,12 +111,16 @@ end
|
|
111
111
|
### Initializer
|
112
112
|
* The gem provides a single initializer, `AppContext`.
|
113
113
|
* This module is **not** name-spaced.
|
114
|
-
|
115
|
-
|
116
|
-
*
|
114
|
+
|
115
|
+
#### Methods
|
116
|
+
* `AppContext#provide_authentication?` method defaults to `true` and
|
117
|
+
can be overridden as required.
|
117
118
|
* For example, `iiab` overrides this initializer so that the
|
118
|
-
`provide_authentication?` method returns `false` unless the app
|
119
|
-
`kh_iiab` (not `demo_im`).
|
119
|
+
`provide_authentication?` method returns `false` unless the app
|
120
|
+
is `kh_iiab` (not `demo_im`).
|
121
|
+
* `AppContext#privileged?` defaults to `nil` and can be overridden as required.
|
122
|
+
* `AppContext#authenticate_for_specs` offers a way to mock
|
123
|
+
authentication and privilege in specs. It accepts a block.
|
120
124
|
|
121
125
|
## Gem Maintenance
|
122
126
|
After many false starts, this repo includes two (seemingly functional) github workflows.
|
@@ -149,9 +153,14 @@ After many false starts, this repo includes two (seemingly functional) github wo
|
|
149
153
|
you.
|
150
154
|
|
151
155
|
## Version History
|
156
|
+
|
157
|
+
### 0.8.1
|
158
|
+
* Tightened up test environment helpers.
|
159
|
+
|
152
160
|
### 0.8.0
|
153
161
|
* Allow RSA signing keys in addition to HMAC.
|
154
162
|
This is because Terraform creates RSA keys during runs.
|
163
|
+
|
155
164
|
### 0.7.4
|
156
165
|
* Use https protocol for callback in production; http otherwise
|
157
166
|
|
@@ -35,13 +35,9 @@ module OauthIm
|
|
35
35
|
def current_user
|
36
36
|
@current_user ||=
|
37
37
|
if user_jwt.present?
|
38
|
-
if email_verified?
|
39
|
-
|
40
|
-
|
41
|
-
head :forbidden
|
42
|
-
end
|
43
|
-
else
|
44
|
-
AppContext.current_user
|
38
|
+
email if email_verified?
|
39
|
+
elsif Rails.env.test?
|
40
|
+
AppContext.spec_user
|
45
41
|
end
|
46
42
|
end
|
47
43
|
|
@@ -5,25 +5,28 @@ module AppContext
|
|
5
5
|
true
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.
|
9
|
-
@
|
8
|
+
def self.privileged?
|
9
|
+
@privileged if provide_authentication?
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.
|
13
|
-
@
|
12
|
+
def self.spec_user
|
13
|
+
@spec_user if Rails.env.test? && provide_authentication?
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.
|
17
|
-
@
|
16
|
+
def self.authenticated_for_specs?
|
17
|
+
@authenticated_for_specs if Rails.env.test? && provide_authentication?
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.authenticate_for_specs(
|
20
|
+
def self.authenticate_for_specs(spec_user: nil, privileged: false)
|
21
|
+
return unless provide_authentication?
|
22
|
+
raise 'Use only in test environment!!' unless Rails.env.test?
|
23
|
+
|
21
24
|
@authenticated_for_specs = true
|
22
|
-
@
|
25
|
+
@spec_user = spec_user
|
23
26
|
@privileged = privileged
|
24
27
|
yield
|
25
28
|
@privileged = false
|
26
|
-
@
|
29
|
+
@spec_user = nil
|
27
30
|
@authenticated_for_specs = false
|
28
31
|
end
|
29
32
|
end
|
data/lib/oauth_im/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth_im
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Connally
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|