yalla_auth_ruby_client 2.0.2 → 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed26f0ec4c3bbede37f49e7aa84537a4b0180521eae5ff18a5c0032dec3df0a5
|
4
|
+
data.tar.gz: a3c298ece7075638dd70eede2c47e121731f184bf93393d3362599d8ec3dfa1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
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.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
|
@@ -115,6 +116,7 @@ files:
|
|
115
116
|
- spec/models/user_spec.rb
|
116
117
|
- spec/spec_helper.rb
|
117
118
|
- yalla_auth_ruby_client-2.0.1.gem
|
119
|
+
- yalla_auth_ruby_client-2.0.2.gem
|
118
120
|
- yalla_auth_ruby_client.gemspec
|
119
121
|
homepage: https://matrix.tn
|
120
122
|
licenses:
|