yalla_auth_ruby_client 2.0.1 → 3.0.0

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: d5d0daaf481f7552506732d1fc02b5adcdd993eaebf7136981817b78eb052849
4
- data.tar.gz: 6e2896599fe4d9820cab1117c45f5f5b91927add54c2b85a01b6aa6b7c4219d6
3
+ metadata.gz: ed26f0ec4c3bbede37f49e7aa84537a4b0180521eae5ff18a5c0032dec3df0a5
4
+ data.tar.gz: a3c298ece7075638dd70eede2c47e121731f184bf93393d3362599d8ec3dfa1c
5
5
  SHA512:
6
- metadata.gz: 493756c3593d198b8a1d2178a7035b620eac083145bd82cae84cfc5bc5b10b837fc0a5bc7ed3c66119ebc87dc45dd7526e79656565ba5990ac1263e00f61a248
7
- data.tar.gz: 9e23efe2ff05c8d85f44d82f32d49fed84966ca3df085bd7d19d4da74dee4e3ec4857fd84fee561353baee6d0de6a9aa12da4beea2a327b7459430a897c17e97
6
+ metadata.gz: 0a77fce078c6d7ceaf91942447c02c0de355a3b08139204cafaaf1320bb96f58a1e2ef38fbf080b05891c8f2b881b72d7ba7c5424e507efab105be3efdec6962
7
+ data.tar.gz: 7d366e763ecd6473613db16c04f4fff32c0617788c2640888c7e19bb7d6ee6ee66dfe8db78a547ab90ec087e79fc91f7a4ce171ba0a86ac71d276fab76844f59
data/README.md CHANGED
@@ -90,6 +90,7 @@ to automatically validate a `token` parameter and store it in a signed cookie.
90
90
  ```ruby
91
91
  # config/application.rb
92
92
  config.middleware.use YallaAuthRubyClient::AuthTokenMiddleware
93
+ # or config.middleware.use YallaAuthRubyClient::UnsignedAuthTokenMiddleware
93
94
  ```
94
95
 
95
96
  ## Getting Started
data/RELEASE.md CHANGED
@@ -1,5 +1,9 @@
1
- # 2.0.0
1
+ # 3.0.0
2
+ Include unsigned_authentication_middleware
3
+ Include Api authentication controller
2
4
 
5
+ # 2.0.0
6
+ Include authentication_middleware
3
7
  Include authenticate_user
4
8
  Breaking changes
5
9
  Include AppUser yalla_id migration
@@ -11,5 +11,5 @@ Generator version: 7.12.0
11
11
  =end
12
12
 
13
13
  module OpenapiClient
14
- VERSION = '2.0.1'
14
+ VERSION = '3.0.0'
15
15
  end
@@ -52,7 +52,7 @@ module YallaAuthRubyClient
52
52
  end
53
53
 
54
54
  def login_redirect_uri
55
- "#{ENV['AUTH_URL']}/users/sign_in?redirect_uri=#{request.original_url}"
55
+ "#{ENV['AUTH_URL']}/users/sign_in?redirect_uri="
56
56
  end
57
57
  end
58
58
  end
@@ -0,0 +1,33 @@
1
+ require "openapi_client"
2
+ require "action_dispatch/middleware/cookies"
3
+
4
+ module YallaAuthRubyClient
5
+ class UnsignedAuthTokenMiddleware
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ request = Rack::Request.new(env)
12
+
13
+ if (token = request.params["token"])
14
+ api_client = OpenapiClient::AuthApi.new
15
+ begin
16
+ response = api_client.auth_validate_token_get(token)
17
+
18
+ if response && response.success
19
+ request_env = ActionDispatch::Request.new(env)
20
+ request_env.cookie_jar[:auth_token] = { value: token, httponly: false }
21
+ end
22
+ rescue OpenapiClient::ApiError => e
23
+ Rails.logger.error "Authentication failed: #{e.message}"
24
+ end
25
+
26
+ clean_url = request.fullpath.gsub(/[\?&]token=[^&]*/, "").sub(/\?$/, "")
27
+ return [302, { "Location" => clean_url, "Content-Type" => "text/html" }, ["Redirecting..."]] unless clean_url == request.fullpath
28
+ end
29
+
30
+ @app.call(env)
31
+ end
32
+ end
33
+ end
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yalla_auth_ruby_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yalla auth openapi client
@@ -104,6 +104,7 @@ files:
104
104
  - lib/yalla_auth_ruby_client/api_controller_authentication.rb
105
105
  - lib/yalla_auth_ruby_client/controller_authentication.rb
106
106
  - lib/yalla_auth_ruby_client/middleware/auth_token_middleware.rb
107
+ - lib/yalla_auth_ruby_client/middleware/unsigned_auth_token_middleware.rb
107
108
  - spec/api/apps_api_spec.rb
108
109
  - spec/api/auth_api_spec.rb
109
110
  - spec/api/users_api_spec.rb
@@ -114,6 +115,8 @@ files:
114
115
  - spec/models/user_role_add_spec.rb
115
116
  - spec/models/user_spec.rb
116
117
  - spec/spec_helper.rb
118
+ - yalla_auth_ruby_client-2.0.1.gem
119
+ - yalla_auth_ruby_client-2.0.2.gem
117
120
  - yalla_auth_ruby_client.gemspec
118
121
  homepage: https://matrix.tn
119
122
  licenses: