model_driven_api 3.4.2 → 3.4.3
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/app/controllers/api/v2/auth/oauth_controller.rb +1 -8
- data/config/routes.rb +2 -3
- data/lib/model_driven_api/version.rb +1 -1
- metadata +1 -2
- data/config/initializers/omniauth.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dab5906eeb7f41358f97e9ca38233e52ad156c2220a18dbea567503a987f8f9
|
4
|
+
data.tar.gz: a37524b760679665f515969501d5672474fa17fc76dcb1f09ee8e852ae11e0e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f8db3a7710aa33b4113541c74ca4d8b8907ccdedc97e38c34057333e8cf4f8dcf8d48a7fa6d650f73f20f5615025a4a03c03bae89bc4097fb313846be422ad6
|
7
|
+
data.tar.gz: 71cc223375df7a9e002a4c9bc68203ae971b43d9d95bef3fa6b9ecf4d594f4cbfa81a158e47f986395812e68ce24448ba93dd1b2b6189fe1f1309ad139ac53fa
|
@@ -1,15 +1,8 @@
|
|
1
1
|
module Api::V2::Auth
|
2
2
|
class OauthController < ActionController::API
|
3
3
|
def callback
|
4
|
-
|
4
|
+
user = ThecoreAuthCommons.check_user params['email'], params['given_name'], params['family_name'], params['provider']
|
5
5
|
|
6
|
-
user = User.find_or_create_by(email: email) do |u|
|
7
|
-
u.name = params['given_name']
|
8
|
-
u.surname = params['family_name']
|
9
|
-
u.password = u.password_confirmation = ThecoreAuthCommons.generate_secure_password
|
10
|
-
u.auth_source = params['provider'] # 'google' or 'microsoft'
|
11
|
-
u.admin = true
|
12
|
-
end
|
13
6
|
unless user
|
14
7
|
render json: { error: "User not registered" }, status: :unauthorized
|
15
8
|
return
|
data/config/routes.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# require 'ransack'
|
2
2
|
|
3
3
|
Rails.application.routes.draw do
|
4
|
-
oauth_test = (ENV['ENTRA_CLIENT_ID'].present? && ENV['ENTRA_CLIENT_SECRET'].present? && ENV['ENTRA_TENANT_ID'].present?) || (ENV['GOOGLE_CLIENT_ID'].present? && ENV['GOOGLE_CLIENT_SECRET'].present?)
|
5
4
|
scope ENV.fetch("RAILS_RELATIVE_URL_ROOT", "/") do
|
6
|
-
if
|
5
|
+
if ThecoreAuthCommons.oauth_vars?
|
7
6
|
# OmniAuth callbacks need these top-level paths:
|
8
7
|
match '/auth/:provider/callback', to: redirect('/api/v2/auth/%{provider}/callback'), via: [:get, :post]
|
9
8
|
match '/auth/failure', to: redirect('/api/v2/auth/failure'), via: [:get, :post]
|
@@ -11,7 +10,7 @@ Rails.application.routes.draw do
|
|
11
10
|
namespace :api, constraints: { format: :json } do
|
12
11
|
namespace :v2 do
|
13
12
|
# Authentication via Oauth2 only if the environment variable is set
|
14
|
-
if
|
13
|
+
if ThecoreAuthCommons.oauth_vars?
|
15
14
|
namespace :auth do
|
16
15
|
# Omniauth routes for OAuth2 authentication
|
17
16
|
match ':provider/callback', to: 'oauth#callback', via: [:get, :post]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_driven_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- config/initializers/after_initialize_for_model_driven_api.rb
|
133
133
|
- config/initializers/cors_api_thecore.rb
|
134
134
|
- config/initializers/knock.rb
|
135
|
-
- config/initializers/omniauth.rb
|
136
135
|
- config/initializers/time_with_zone.rb
|
137
136
|
- config/initializers/wrap_parameters.rb
|
138
137
|
- config/routes.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Rails.application.config.middleware.use OmniAuth::Builder do
|
2
|
-
provider(
|
3
|
-
:entra_id,
|
4
|
-
{
|
5
|
-
client_id: ENV['ENTRA_CLIENT_ID'],
|
6
|
-
client_secret: ENV['ENTRA_CLIENT_SECRET'],
|
7
|
-
tenant_id: ENV['ENTRA_TENANT_ID'], # Needed for Microsoft
|
8
|
-
scope: 'User.Read',
|
9
|
-
response_type: 'code'
|
10
|
-
}
|
11
|
-
)
|
12
|
-
provider :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], {
|
13
|
-
scope: 'email,profile',
|
14
|
-
prompt: 'select_account',
|
15
|
-
access_type: 'online'
|
16
|
-
}
|
17
|
-
end
|
18
|
-
|
19
|
-
OmniAuth.config.allowed_request_methods = [:get, :post]
|
20
|
-
OmniAuth.config.silence_get_warning = true
|