oauth_im 0.1.0 → 0.4.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/README.md +22 -11
- data/app/controllers/concerns/oauth_im/authenticable.rb +5 -6
- data/app/controllers/oauth_im/client_controller.rb +1 -1
- data/lib/oauth_im/version.rb +1 -1
- metadata +49 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a70d55e5fdd5e744b2dc73080162d95b932e18a889b8705e9ccddbb17ac04058
|
4
|
+
data.tar.gz: 253c1abec16f1895b8c4a663b46ac01699b46d81248ff5e661854445783987a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73134ec8ba1250f443cd82f3f8ceea8ef1634967d19f0fcfe9dc0bc41dbf34dc6f3769daf4040e57eceb5ec960fb045c22e2a7187a77cbb873167be109c0348b
|
7
|
+
data.tar.gz: 9de025db4311239f823a0503abb80a84b21ab663272c607a029f7aa4d5d1dbd7223140b13d6e162eacd65cd2a09e3cfbde850b8dbd504403d8aab2c7545627b5
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ apps.
|
|
8
8
|
Add this line to your application's Gemfile:
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'oauth_im'
|
11
|
+
gem 'oauth_im', '0.x.y' # e.g., '0.1.2'
|
12
12
|
```
|
13
13
|
|
14
14
|
Then run:
|
@@ -39,9 +39,9 @@ end
|
|
39
39
|
|
40
40
|
* The `ENV` variable values can be obtained from the OAuth provider.
|
41
41
|
* The `callback_path` setting is used in two related ways:
|
42
|
-
* It defines a route to the `OAuthIm::ClientController#callback`
|
43
|
-
action.
|
44
|
-
* It defines a callback URL used by the OAuth provider.
|
42
|
+
* It [defines a route](https://github.com/illustrativemathematics/oauth_im/blob/main/config/routes.rb#L4) to the [`OAuthIm::ClientController#callback`
|
43
|
+
action](https://github.com/illustrativemathematics/oauth_im/blob/main/app/controllers/oauth_im/client_controller.rb#L7-L12).
|
44
|
+
* It defines a [callback URL](https://github.com/illustrativemathematics/oauth_im/blob/main/app/controllers/oauth_im/client_controller.rb#L69) used by the OAuth provider.
|
45
45
|
* Note that this callback URL must be whitelisted at the provider.
|
46
46
|
At FusionAuth, this is done under the `Applications|OAuth` tab.
|
47
47
|
* For instance, for the app `staging-kh-iiab.herokuapp.com`, if
|
@@ -52,23 +52,34 @@ end
|
|
52
52
|
|
53
53
|
## Usage
|
54
54
|
### Helpers for Logging in and Out
|
55
|
-
The engine provides two
|
55
|
+
The engine provides [two endpoints](https://github.com/illustrativemathematics/oauth_im/blob/main/config/routes.rb#L5-L6) for logging in and out, and exposes
|
56
56
|
corresponding view helpers. These are accessible from the main app as:
|
57
|
-
* `oauth_im.login_path` or `oauth_im.login_url`
|
58
|
-
* `oauth_im.logout_path` or `oauth_im.logout_url`
|
59
57
|
|
60
|
-
|
58
|
+
| path | url |
|
59
|
+
|------|-----|
|
60
|
+
| `oauth_im.login_path` | `oauth_im.login_url` |
|
61
|
+
| `oauth_im.logout_path` | `oauth_im.logout_url` |
|
61
62
|
|
62
|
-
|
63
|
+
* Note that the helpers are namespaced to the engine.
|
64
|
+
|
65
|
+
The [controller actions](https://github.com/illustrativemathematics/oauth_im/blob/main/app/controllers/oauth_im/client_controller.rb#L14-L21) for these routes are provided and should "just
|
63
66
|
work." Note that there are no view templates associated with these
|
64
67
|
actions, since requests to them are redirected to the OAuth provider.
|
65
68
|
|
66
69
|
### Helpers for User ID and Authentication
|
67
70
|
The gem provides a controller concern, `OauthIm::Authenticable`, that
|
68
|
-
exposes two helper methods for use in views:
|
71
|
+
exposes [two helper methods](https://github.com/illustrativemathematics/oauth_im/blob/main/app/controllers/concerns/oauth_im/authenticable.rb#L9-L10) for use in views:
|
69
72
|
* `authenticated?`: returns `true` if the user has been authenticated
|
70
73
|
by the OAuth service, false otherwise.
|
71
74
|
* `email`: returns the current user's authenticated email address.
|
72
75
|
|
73
76
|
You can include this concern in your app's `ApplicationController` or
|
74
|
-
some other appropriate location.
|
77
|
+
some other appropriate location, e.g.:
|
78
|
+
``` ruby
|
79
|
+
class ApplicationController < ActionController::Base
|
80
|
+
include OauthIm::Authenticable
|
81
|
+
|
82
|
+
# etc. etc. etc.
|
83
|
+
end
|
84
|
+
|
85
|
+
```
|
@@ -5,7 +5,6 @@ module OauthIm
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
before_action :auth_uid
|
9
8
|
helper_method :authenticated?
|
10
9
|
helper_method :email
|
11
10
|
end
|
@@ -20,10 +19,6 @@ module OauthIm
|
|
20
19
|
@email ||= jwt_token['email']
|
21
20
|
end
|
22
21
|
|
23
|
-
def auth_uid
|
24
|
-
gon.user_id = session[:user_jwt]['value'].first['jti'] if authenticated?
|
25
|
-
end
|
26
|
-
|
27
22
|
def user_jwt
|
28
23
|
@user_jwt ||= session[:user_jwt] || {}
|
29
24
|
end
|
@@ -48,7 +43,11 @@ module OauthIm
|
|
48
43
|
end
|
49
44
|
|
50
45
|
def logged_in?
|
51
|
-
current_user.present?
|
46
|
+
current_user.present? || local_login?
|
47
|
+
end
|
48
|
+
|
49
|
+
def local_login?
|
50
|
+
session[:userinfo].present?
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -21,7 +21,7 @@ module OauthIm
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def local_login
|
24
|
-
raise 'Disallowed'
|
24
|
+
raise 'Disallowed' if Rails.env.production?
|
25
25
|
|
26
26
|
session[:userinfo] = { info: { email: 'local_login@example.com' } }
|
27
27
|
redirect_back(fallback_location: main_app.root_path)
|
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.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Connally
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -66,6 +66,48 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.23.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.23.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.21'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.21'
|
69
111
|
description: Include this gem in Gemfile, add an initializer, and you are good to
|
70
112
|
go.
|
71
113
|
email:
|
@@ -95,10 +137,11 @@ homepage: https://github.com/illustrativemathematics/oauth_im
|
|
95
137
|
licenses:
|
96
138
|
- BSD-3-Clause
|
97
139
|
metadata:
|
140
|
+
changelog_uri: https://github.com/illustrativemathematics/oauth_im
|
98
141
|
homepage_uri: https://github.com/illustrativemathematics/oauth_im
|
99
142
|
source_code_uri: https://github.com/illustrativemathematics/oauth_im
|
100
|
-
|
101
|
-
post_install_message:
|
143
|
+
rubygems_mfa_required: 'true'
|
144
|
+
post_install_message:
|
102
145
|
rdoc_options: []
|
103
146
|
require_paths:
|
104
147
|
- lib
|
@@ -114,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
157
|
version: '0'
|
115
158
|
requirements: []
|
116
159
|
rubygems_version: 3.0.3
|
117
|
-
signing_key:
|
160
|
+
signing_key:
|
118
161
|
specification_version: 4
|
119
162
|
summary: Provide oauth functionality for IM apps.
|
120
163
|
test_files: []
|