yalla_auth_ruby_client 2.0.2 → 3.0.1
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/README.md +1 -0
- data/RELEASE.md +5 -1
- data/lib/openapi_client/version.rb +1 -1
- data/lib/yalla_auth_ruby_client/middleware/unsigned_auth_token_middleware.rb +33 -0
- data/lib/yalla_auth_ruby_client.rb +1 -0
- data/yalla_auth_ruby_client-3.0.0.gem +0 -0
- metadata +3 -2
- data/yalla_auth_ruby_client-2.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f923fb449e9461e33ee91707057343e018bf974604e32527a7506084d07487
|
4
|
+
data.tar.gz: 8721a346d1fd2a0ba894838587904dd8d4693915c85fed929600903af6104d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8707ab477ffc7734e92602a2d5cd2cc1e7590ce97b81f8ae20d6019805698351b4be8f527612d17c72069962e63b6b739a08b13ab761195fd04e666153313aee
|
7
|
+
data.tar.gz: e18b6934a9115d436263eed7ab2b75651d71cc0c2d9dfcbd2806655ab64c980c5da5a4bf8f50210b1d003bfa0f63a8be9296a0a31919a49f72d72abc23a1ab59
|
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
@@ -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
|
@@ -3,6 +3,7 @@ require 'rails/railtie'
|
|
3
3
|
require 'yalla_auth_ruby_client/controller_authentication'
|
4
4
|
require 'yalla_auth_ruby_client/api_controller_authentication'
|
5
5
|
require 'yalla_auth_ruby_client/middleware/auth_token_middleware'
|
6
|
+
require 'yalla_auth_ruby_client/middleware/unsigned_auth_token_middleware'
|
6
7
|
|
7
8
|
module YallaAuthRubyClient
|
8
9
|
class Engine < ::Rails::Engine
|
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:
|
4
|
+
version: 3.0.1
|
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,7 +115,7 @@ files:
|
|
114
115
|
- spec/models/user_role_add_spec.rb
|
115
116
|
- spec/models/user_spec.rb
|
116
117
|
- spec/spec_helper.rb
|
117
|
-
- yalla_auth_ruby_client-
|
118
|
+
- yalla_auth_ruby_client-3.0.0.gem
|
118
119
|
- yalla_auth_ruby_client.gemspec
|
119
120
|
homepage: https://matrix.tn
|
120
121
|
licenses:
|
Binary file
|