model_driven_api 3.12.1 → 3.12.2
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 +9 -1
- data/config/routes.rb +3 -2
- data/lib/model_driven_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 64d6dc96e02bf63e76a9948d41e1f7203433f9be2f3bb0a2abe16f19179351ad
|
|
4
|
+
data.tar.gz: 47bf8c07a5e6381bcabb15a150faae8bd08ae02000db9798c091b2a916e628df
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d7039ac2e39aa75800db5a1ecdabd121a7465c8ffdc966ab88dac7961e53bd00eff37c0b8794b5d6ecca68f5a8d9eed3e4a3a8dd9d800a084301e12a7e321b0
|
|
7
|
+
data.tar.gz: 37566ee9050bfe09de0f3d784d0c6b4b6aebb39ec365ceb8c7f59e045b4865d3bf66518ebd1a393c38a8a04db575a2bd3ee2c106df84551f17e79c2b27c33780
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
module Api::V2::Auth
|
|
2
2
|
class OauthController < ActionController::API
|
|
3
|
+
# L'identità arriva solo da request.env['omniauth.auth'], che il middleware OmniAuth imposta
|
|
4
|
+
# dopo aver verificato il login col provider; mai dai parametri della richiesta, che chiunque
|
|
5
|
+
# può inviare (fino alla 3.12.1 bastava una POST con email= per avere il JWT di quell'utente).
|
|
3
6
|
def callback
|
|
4
|
-
|
|
7
|
+
auth = request.env['omniauth.auth']
|
|
8
|
+
info = auth&.info
|
|
9
|
+
user = info && ThecoreAuthCommons.check_user(info.email,
|
|
10
|
+
info.first_name.presence || info.name,
|
|
11
|
+
info.last_name,
|
|
12
|
+
auth.provider)
|
|
5
13
|
|
|
6
14
|
unless user
|
|
7
15
|
render json: { error: "User not registered" }, status: :unauthorized
|
data/config/routes.rb
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Rails.application.routes.draw do
|
|
4
4
|
scope ENV.fetch("RAILS_RELATIVE_URL_ROOT", "/") do
|
|
5
5
|
if ThecoreAuthCommons.oauth_vars?
|
|
6
|
-
# OmniAuth callbacks need these top-level paths:
|
|
7
|
-
|
|
6
|
+
# OmniAuth callbacks need these top-level paths. The callback goes straight to the controller:
|
|
7
|
+
# a redirect would drop the verified request.env['omniauth.auth'] the middleware has just set.
|
|
8
|
+
match "/auth/:provider/callback", to: "api/v2/auth/oauth#callback", via: [:get, :post], defaults: { format: :json }
|
|
8
9
|
match "/auth/failure", to: redirect("/api/v2/auth/failure"), via: [:get, :post]
|
|
9
10
|
end
|
|
10
11
|
namespace :api, constraints: { format: :json } do
|