agreeable-lifeguard-99976
02/16/2023, 2:04 PM# config/initializers/ory_client.rb
OryClient.configure do |config|
config.access_token = 'YOUR_BEARER_TOKEN'
config.api_key = {}
config.api_key_prefix
# config.base_path = "<http://localhost:5200>"
config.cert_file = nil
config.client_side_validation = false
config.debugging = false
config.force_ending_format = false
config.host = "<https://SLUG.projects.oryapis.com>"
config.inject_format = false
config.key_file = nil
config.logger = ActiveSupport::Logger #‹ActiveSupport::Logger:0x0000000107c4ebb0>
config.params_encoding = nil
config.scheme = "https"
config.server_index = nil # see this issue: <https://github.com/ory/kratos-client-ruby/issues/3#issuecomment-955609406>
config.server_operation_index = {}
config.server_operation_variables = {}
config.server_variables = {}
config.timeout = 0
config.verify_ssl = false
config.verify_ssl_host = false
end
# app/controllers/auth_controller.rb
class ApplicationController < ActionController::Base
before_action :ory_client
def ory_client
@_ory_client ||= OryClient::FrontendApi.new
end
end
# app/controllers/auth_controller.rb
class AuthController < ApplicationController
def login
redirect_to login_flow_url, allow_other_host: true
end
private
def login_flow_url
res = ory_client.create_browser_login_flow
res.ui.action
end
end
# app/controllers/callback_controller.rb
class CallbackController < ApplicationController
def index
cookies # <ActionDispatch::Cookies::CookieJar:0x000000011566fec0 @set_cookies={}, @delete_cookies={}, @request=#<ActionDispatch::Request GET \"<http://localhost:3000/auth/callback>\" for 127.0.0.1>, @cookies={\"_poc1_sc1_app1_session\"=>\"12StaGYYebeaIrtRs5djlrGSuQzLEsMHbWOPjgCSNQmdcayikSU4J6C2aWmrzAZhXX1mfOIeeDTH5vLIyvPp6lw6XAMP9B7sqXdJquhac7Ndx7tJCS0gHaUjbJjMa14AK5FuW3QcSzZHMlhDl5vLFx5YSAHmi1vlzWkU1zVyA+Mr2io3s0zuAICX4eZhyTth7ftC064Qw+UdDLwmLEnbZzc93JOLIxhS5rnBUUi2qEZAGT/+Oczp+ZI335S9rVSm8A2hk5yflxQbIT5ZNTRSqZKqQqk3dgM+gL5Eiff9--qHcaT6bYkC9QtCzT--2AbFwmOTOfDQjWy3jmT+sQ==\"}, @committed=false>"
headers # {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"0", "X-Content-Type-Options"=>"nosniff", "X-Download-Options"=>"noopen", "X-Permitted-Cross-Domain-Policies"=>"none", "Referrer-Policy"=>"strict-origin-when-cross-origin"}
session #<ActionDispatch::Request::Session:0xc670 not yet loaded>
# ory_client.to_session
redirect_to root_path
end
end
proud-plumber-24205
02/16/2023, 2:09 PMproud-plumber-24205
02/16/2023, 2:09 PMproud-plumber-24205
02/16/2023, 2:10 PMagreeable-lifeguard-99976
02/16/2023, 2:11 PMproud-plumber-24205
02/16/2023, 2:14 PM<http://localhost:4000>
proud-plumber-24205
02/16/2023, 2:15 PM<https://localhost:4000/ui/login>
agreeable-lifeguard-99976
02/16/2023, 2:23 PMagreeable-lifeguard-99976
02/16/2023, 2:24 PM<https://localhost:4000/ui/login>
agreeable-lifeguard-99976
02/16/2023, 2:25 PMagreeable-lifeguard-99976
02/16/2023, 2:28 PMproud-plumber-24205
02/16/2023, 2:36 PM/.ory/
path.
For example, you are running the proxy under <http://localhost:3000>
and your application is under <http://localhost:4000>
then Ory will live under <http://localhost:3000/.ory/ui/login>
. So in the UI you would need to point to <http://localhost:3000/.ory>
I generally recommend using the Ory CLI tunnel since it is a "sidecar" to the UI, leaving the UI to be accessed directly by the browser instead of "through" the proxy. I think the documentation here still uses the Ory proxy as an example, which I think we should update 😅