foobara-auth-http 0.1.0 → 0.1.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: 62b67f4f6ae5108b39697d7c792e33854f1a9f79d2bd9a00cdd28999a15330be
4
- data.tar.gz: 99efd48356f66e58aeb1c387cf54f5b08a3de61bfb7ab68c58a8d88f34e244c7
3
+ metadata.gz: 016bcd816d77d49551a798013b1f1dc00a2b90999c7495b780d75262e8a847af
4
+ data.tar.gz: f3ea2ca603b95d0f31d38f46496cc95475a07d0c7fa9eaa1fdbd50f30ea566f0
5
5
  SHA512:
6
- metadata.gz: d9973773609190f3b369a29dbaba12e67d17b048baf4bd44091a00b3d1491d60328c8af38f42c922bac6187b2d30abc12b8799fe9c8fdf866d2fb62453dfb78e
7
- data.tar.gz: db20a0f1870d0048d0cb59f628707470b36af8403c1dd04a718a4459f54fb918f29ab242bfe2962e5c9dc5b8a0e3cab3572a9103a8af415f11edf2a627000a45
6
+ metadata.gz: 695c59e8167f0289cbc2c81e9d90c81829759fac4ee98ec9ffc5aeae79fea61f3cfadc7701ee08401ae77cb43f508b1521fdc4cf864a3172453bf59a1d5431d1
7
+ data.tar.gz: 373df4a3e625b0fd16e5a331907c702ff55436a74647613e01f473793688e6e35ffa8709fb2584c89e9b392dffa56492f930c2ec59e408edb24d3661e169e721
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [0.1.2] - 2026-02-16
2
+
3
+ - Add a :logs_out desugarizer
4
+
5
+ ## [0.1.1] - 2026-01-27
6
+
7
+ - Use lower-case header keys to appease Rack::Lint
8
+
1
9
  ## [0.1.0] - 2025-08-22
2
10
 
3
11
  - Mark as compatible with Foobara 0.1.0
data/README.md CHANGED
@@ -75,13 +75,13 @@ A rundown of everything happening here:
75
75
  * We are declaring that we want to authenticate using bearer tokens. These are JWT tokens in an
76
76
  `Authorization: Bearer <token>` header.
77
77
  * We are declaring that when we login or refresh our login, we would like to move the new access token
78
- from the result to an X-Access-Token header, and we would like
78
+ from the result to an x-access-token header, and we would like
79
79
  to move the new refresh token from the result to a secure http only cookie.
80
80
  * We are declaring that when we want to refresh our login, we want to move the refresh token from the
81
81
  headers to an input to RefreshLogin.
82
82
  * Logout could technically be handled by the client but for convenience/added safety, we expose
83
83
  Logout and move the refresh token to its inputs so that it can invalidate the refresh token.
84
- * When we respond from Logout, we set the X-Access-Token header to nil. This is something the client
84
+ * When we respond from Logout, we set the x-access-token header to nil. This is something the client
85
85
  could do but gives an easy way to clobber the client's access token without effort on their end.
86
86
 
87
87
  We also expose a few app commands using our authenticator. This is configured as part of command connectors not
@@ -8,8 +8,9 @@ module Foobara
8
8
 
9
9
  class << self
10
10
  def install!
11
- CommandConnectors::Http.register_authenticator(BearerAuthenticator)
12
- CommandConnectors::Http.register_authenticator(ApiKeyAuthenticator)
11
+ CommandConnectors::Http.register_authenticator BearerAuthenticator
12
+ CommandConnectors::Http.register_authenticator ApiKeyAuthenticator
13
+ CommandConnectors::Http.add_desugarizer Desugarizers::LogsOut
13
14
  end
14
15
  end
15
16
  end
@@ -0,0 +1,24 @@
1
+ module Foobara
2
+ module AuthHttp
3
+ module Desugarizers
4
+ class LogsOut < CommandConnectors::Desugarizer
5
+ def applicable?(args_and_opts)
6
+ args_and_opts.last[:logs_out]
7
+ end
8
+
9
+ def desugarize(args_and_opts)
10
+ args, opts = args_and_opts
11
+
12
+ opts = opts.merge(
13
+ request_mutators: Foobara::AuthHttp::SetRefreshTokenFromCookie,
14
+ response_mutators: Foobara::AuthHttp::ClearAccessTokenHeader
15
+ )
16
+
17
+ opts.delete(:logs_out)
18
+
19
+ [args, opts]
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,6 @@
1
1
  module Foobara
2
2
  module AuthHttp
3
+ # Is this genuinely a generic enough concept to be a class in this project?
3
4
  class SetUserToAuthenticatedUser < Foobara::CommandConnectors::Http::SetInputToProcResult
4
5
  # TODO: move this into base class as default?
5
6
  class << self
@@ -8,7 +8,7 @@ module Foobara
8
8
  end
9
9
  end
10
10
 
11
- def initialize(header_name = "X-Access-Token", header_value = nil)
11
+ def initialize(header_name = "x-access-token", header_value = nil)
12
12
  super()
13
13
 
14
14
  self.header_name = header_name.to_s
@@ -8,7 +8,7 @@ module Foobara
8
8
  end
9
9
  end
10
10
 
11
- def initialize(attribute_name = :access_token, header_name = "X-Access-Token")
11
+ def initialize(attribute_name = :access_token, header_name = "x-access-token")
12
12
  super()
13
13
 
14
14
  self.attribute_name = attribute_name.to_sym
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-auth-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -69,13 +69,14 @@ files:
69
69
  - LICENSE.txt
70
70
  - README.md
71
71
  - lib/foobara/auth_http.rb
72
- - src/foobara/auth_http/api_key_authenticator.rb
73
- - src/foobara/auth_http/bearer_authenticator.rb
74
- - src/foobara/auth_http/clear_access_token_header.rb
75
- - src/foobara/auth_http/move_access_token_to_header.rb
76
- - src/foobara/auth_http/move_refresh_token_to_cookie.rb
77
- - src/foobara/auth_http/set_refresh_token_from_cookie.rb
78
- - src/foobara/auth_http/set_user_to_authenticated_user.rb
72
+ - src/authenticators/api_key_authenticator.rb
73
+ - src/authenticators/bearer_authenticator.rb
74
+ - src/desugarizers/logs_out.rb
75
+ - src/request_mutators/set_refresh_token_from_cookie.rb
76
+ - src/request_mutators/set_user_to_authenticated_user.rb
77
+ - src/response_mutators/clear_access_token_header.rb
78
+ - src/response_mutators/move_access_token_to_header.rb
79
+ - src/response_mutators/move_refresh_token_to_cookie.rb
79
80
  homepage: https://github.com/foobara/auth-http
80
81
  licenses:
81
82
  - Apache-2.0 OR MIT