model_driven_api 3.12.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0877810a34bb2f213343f3e5f13bfee52b0cec2d8da29431c64466185078d01b'
4
- data.tar.gz: d52e6f70ae1da5655ab7b5ad605c400c88ed659d84425b91e5a239506d2d9d6a
3
+ metadata.gz: 64d6dc96e02bf63e76a9948d41e1f7203433f9be2f3bb0a2abe16f19179351ad
4
+ data.tar.gz: 47bf8c07a5e6381bcabb15a150faae8bd08ae02000db9798c091b2a916e628df
5
5
  SHA512:
6
- metadata.gz: 2a557cb8c023b0e98fc299c3c2334e6720faa58f2383f8f207ad53a5d00f6b66a8b92c9756d467aed8b02a21fc0beb145c5eb92d3fe20ca226de2963fe4ef7ab
7
- data.tar.gz: eccaf19b8ecdf2c13283c3918ec4be6d1d8c27d4e52b1e37490ddae532720be75a03a11853f882bb14778c141198cb123f2c610a518d3397b351157e7de523b9
6
+ metadata.gz: 6d7039ac2e39aa75800db5a1ecdabd121a7465c8ffdc966ab88dac7961e53bd00eff37c0b8794b5d6ecca68f5a8d9eed3e4a3a8dd9d800a084301e12a7e321b0
7
+ data.tar.gz: 37566ee9050bfe09de0f3d784d0c6b4b6aebb39ec365ceb8c7f59e045b4865d3bf66518ebd1a393c38a8a04db575a2bd3ee2c106df84551f17e79c2b27c33780
data/README.md CHANGED
@@ -73,7 +73,7 @@ bundle exec rails db:migrate
73
73
  POST /api/v2/authenticate
74
74
  Content-Type: application/json
75
75
 
76
- { "auth": { "email": "admin@example.com", "password": "Change#1" } }
76
+ { "auth": { "email": "admin@example.com", "password": "<password>" } }
77
77
  ```
78
78
 
79
79
  Response body: User JSON. Response header: `Token: <jwt>`.
@@ -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
- user = ThecoreAuthCommons.check_user params['email'], params['given_name'], params['family_name'], params['provider']
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
- match "/auth/:provider/callback", to: redirect("/api/v2/auth/%{provider}/callback"), via: [:get, :post]
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
@@ -732,7 +732,7 @@ To begin a session, the client must POST user credentials to the authentication
732
732
  {
733
733
  "auth": {
734
734
  "email": "admin@example.com",
735
- "password": "Change#1"
735
+ "password": "<password>"
736
736
  }
737
737
  }
738
738
 
@@ -1,3 +1,3 @@
1
1
  module ModelDrivenApi
2
- VERSION = "3.12.0".freeze
2
+ VERSION = "3.12.2".freeze
3
3
  end
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.12.0
4
+ version: 3.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni