infinum_azure 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +26 -0
- data/app/controllers/infinum_azure/api/webhooks_controller.rb +33 -0
- data/config/routes.rb +8 -0
- data/lib/infinum_azure/version.rb +1 -1
- data/lib/infinum_azure.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91e15ff1b9c4d10efe59515afefabb3d7cf30ab4e5db48a7f6d6a9a0ba0becd9
|
4
|
+
data.tar.gz: 2b9b9d955b4f66d029da9243ce62430988a040ae7995a12bd13d3059f07c1a07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c99b0116be82397a78d57d24f98de0cc8fbd2d26e1ee22b3a565205c1cfff1ea4598e507ed62071ed4d9f6446e9223e72c5f024f4d7ed968b54a56fff9e41583
|
7
|
+
data.tar.gz: 5c74771724c5bc818b7df7c78cfa27c14ebfb29948e226e01b5fb92014a24371ec39295cda1a06d33b1f92221942f1d00a58c99b023753b40bfc5bb99c63b3d6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -43,12 +43,14 @@ Or install it yourself as:
|
|
43
43
|
InfinumAzure.configure do |config|
|
44
44
|
config.service_name = 'Revisor'
|
45
45
|
config.resource_name = 'User'
|
46
|
+
config.resource_attributes = [:uid, :email, :first_name, :last_name]
|
46
47
|
end
|
47
48
|
```
|
48
49
|
|
49
50
|
Configuration options:
|
50
51
|
* Service name - name of application
|
51
52
|
* Resource name - name of resource on whom authentication is being done
|
53
|
+
* Resource attributes - attributes sent from InfinumAzure when user is created/updated that will be permitted
|
52
54
|
|
53
55
|
### Secrets
|
54
56
|
|
@@ -102,6 +104,30 @@ or, if you just want to clear the session, but not log out of Infinum Azure, you
|
|
102
104
|
link_to 'Logout', logout_path
|
103
105
|
```
|
104
106
|
|
107
|
+
## Known issues
|
108
|
+
|
109
|
+
If you don't get what you're looking for, check your terminal output and see if omniauth logs are saying anything similar to:
|
110
|
+
|
111
|
+
```
|
112
|
+
DEBUG -- omniauth: (google_oauth2) Request phase initiated.
|
113
|
+
WARN -- omniauth: Attack prevented by OmniAuth::AuthenticityTokenProtection
|
114
|
+
ERROR -- omniauth: (google_oauth2) Authentication failure! authenticity_error: OmniAuth::AuthenticityError, Forbidden
|
115
|
+
```
|
116
|
+
|
117
|
+
To resolve this issue, install the omniauth-rails_csrf_protection gem:
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
gem 'omniauth-rails_csrf_protection'
|
121
|
+
```
|
122
|
+
|
123
|
+
Make sure to use HTTP method POST for authenticating. If you are using a link, you can set the HTTP method to POST like this:
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
link_to 'Login', user_infinum_azure_omniauth_authorize_path, method: :post
|
127
|
+
```
|
128
|
+
|
129
|
+
or, simply with `#button_to` as mentioned above.
|
130
|
+
|
105
131
|
## License
|
106
132
|
|
107
133
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module InfinumAzure
|
4
|
+
module Api
|
5
|
+
class WebhooksController < Api::BaseController
|
6
|
+
def upsert_resource_callback
|
7
|
+
if resource
|
8
|
+
resource.update(user_params)
|
9
|
+
action = 'updated'
|
10
|
+
else
|
11
|
+
resource_class.create(user_params)
|
12
|
+
action = 'created'
|
13
|
+
end
|
14
|
+
|
15
|
+
render json: { resource_name.underscore => action }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def resource
|
21
|
+
@resource ||= resource_class.where(uid: user_params[:uid], provider: InfinumAzure.provider).or(
|
22
|
+
resource_class.where(email: user_params[:email])
|
23
|
+
).first
|
24
|
+
end
|
25
|
+
|
26
|
+
def user_params
|
27
|
+
params.require(:user)
|
28
|
+
.permit(InfinumAzure.resource_attributes)
|
29
|
+
.merge(provider: InfinumAzure.provider)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/config/routes.rb
CHANGED
@@ -7,4 +7,12 @@ Rails.application.routes.draw do
|
|
7
7
|
devise_for InfinumAzure.resource_name.pluralize.underscore, controllers: {
|
8
8
|
omniauth_callbacks: 'infinum_azure/resources/omniauth_callbacks'
|
9
9
|
}
|
10
|
+
|
11
|
+
namespace :infinum_azure do
|
12
|
+
namespace :api do
|
13
|
+
scope '/webhooks', controller: :webhooks do
|
14
|
+
post :upsert_resource_callback
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
10
18
|
end
|
data/lib/infinum_azure.rb
CHANGED
@@ -12,6 +12,11 @@ module InfinumAzure
|
|
12
12
|
|
13
13
|
setting :service_name, reader: true
|
14
14
|
setting :resource_name, default: 'User', reader: true
|
15
|
+
setting :resource_attributes, default: [:uid, :email, :first_name, :last_name], reader: true
|
16
|
+
|
17
|
+
def self.provider
|
18
|
+
to_s.underscore
|
19
|
+
end
|
15
20
|
|
16
21
|
def self.resource_class
|
17
22
|
resource_name.constantize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infinum_azure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marko Ćilimković
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -299,6 +299,7 @@ files:
|
|
299
299
|
- README.md
|
300
300
|
- Rakefile
|
301
301
|
- app/controllers/infinum_azure/api/base_controller.rb
|
302
|
+
- app/controllers/infinum_azure/api/webhooks_controller.rb
|
302
303
|
- app/controllers/infinum_azure/application_controller.rb
|
303
304
|
- app/controllers/infinum_azure/resources/omniauth_callbacks_controller.rb
|
304
305
|
- app/controllers/infinum_azure/resources_controller.rb
|