Module: Machina
- Defined in:
- lib/machina.rb,
lib/machina/engine.rb,
lib/machina/errors.rb,
lib/machina/current.rb,
lib/machina/version.rb,
lib/machina/authorized.rb,
lib/machina/test_helpers.rb,
lib/machina/configuration.rb,
lib/machina/workspace_ref.rb,
lib/machina/identity_client.rb,
lib/machina/permission_sync.rb,
lib/machina/webhook_receiver.rb,
lib/machina/workspace_scoped.rb,
lib/machina/controller_helpers.rb,
lib/generators/machina/install_generator.rb,
app/controllers/machina/webhooks_controller.rb,
lib/machina/middleware/authentication/hints.rb
Overview
Machina is a Ruby gem that provides authentication and authorization integration with the ZAR Machina Console identity service.
Defined Under Namespace
Modules: ControllerHelpers, Generators, Middleware, TestHelpers, WorkspaceScoped Classes: Authorized, Configuration, ConfigurationError, Current, Engine, Error, IdentityClient, PermissionSync, Unauthorized, WebhookReceiver, WebhooksController, WorkspaceRef
Constant Summary collapse
- VERSION =
'0.3.0'
Class Method Summary collapse
-
.authorize_url(redirect_to: nil, return_to: nil) ⇒ String
Builds the Console authorize URL.
- .cache ⇒ Object
- .config ⇒ Object
- .configure {|config| ... } ⇒ Object
- .identity_client ⇒ Object
-
.login_url(return_to:) ⇒ String
Convenience wrapper that delegates to Machina.authorize_url with
return_to. - .reset! ⇒ Object
Class Method Details
.authorize_url(redirect_to: nil, return_to: nil) ⇒ String
Builds the Console authorize URL.
The Console’s /authorize endpoint requires a redirect_to query param so it knows where to send the user after workspace selection. This method always produces that param — the two keyword arguments control how:
-
*Callback-based (preferred)* — uses the configured
identity_callback_urias the redirect target. Passreturn_toto append the user’s intended destination as a query param on the callback. -
Explicit — pass
redirect_todirectly to bypass callback resolution. Intended for backwards compatibility only.
77 78 79 80 81 82 |
# File 'lib/machina.rb', line 77 def (redirect_to: nil, return_to: nil) redirect_target = redirect_to.presence || callback_redirect_target(return_to) base = config.identity_service_url.to_s.sub(%r{/\z}, '') "#{base}/authorize?redirect_to=#{CGI.escape(redirect_target)}" end |
.cache ⇒ Object
54 55 56 |
# File 'lib/machina.rb', line 54 def cache config.cache_store || Rails.cache end |
.config ⇒ Object
41 42 43 |
# File 'lib/machina.rb', line 41 def config @config ||= Configuration.new end |
.configure {|config| ... } ⇒ Object
37 38 39 |
# File 'lib/machina.rb', line 37 def configure yield(config) end |
.identity_client ⇒ Object
50 51 52 |
# File 'lib/machina.rb', line 50 def identity_client @identity_client ||= IdentityClient.new(config:) end |
.login_url(return_to:) ⇒ String
Convenience wrapper that delegates to authorize_url with return_to.
88 89 90 |
# File 'lib/machina.rb', line 88 def login_url(return_to:) (return_to:) end |
.reset! ⇒ Object
45 46 47 48 |
# File 'lib/machina.rb', line 45 def reset! @config = Configuration.new @identity_client = nil end |