Class: YiffSpace::Auth::Client
- Inherits:
-
Object
- Object
- YiffSpace::Auth::Client
- Defined in:
- lib/yiffspace/auth/client.rb
Instance Attribute Summary collapse
-
#auth_session_key ⇒ Object
Returns the value of attribute auth_session_key.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
-
#permissions_separator ⇒ Object
Returns the value of attribute permissions_separator.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#scopes ⇒ Object
Returns the value of attribute scopes.
-
#server_url ⇒ Object
Returns the value of attribute server_url.
-
#update_discord_images ⇒ Object
Returns the value of attribute update_discord_images.
-
#user_session_key ⇒ Object
Returns the value of attribute user_session_key.
Instance Method Summary collapse
-
#initialize(name) ⇒ Client
constructor
A new instance of Client.
- #logto(controller) ⇒ Object
Constructor Details
#initialize(name) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/yiffspace/auth/client.rb', line 14 def initialize(name) @name = name.to_sym @scopes = %i[openid offline_access profile roles identities] @permissions = [] @redirect_uri = "http://127.0.0.1:3000/auth/cb" @server_url = "https://auth.yiff.space" @auth_session_key = :"yiffspace_auth_#{name}" @user_session_key = :"yiffspace_user_#{name}" @update_discord_images = true @permissions_separator = ":" end |
Instance Attribute Details
#auth_session_key ⇒ Object
Returns the value of attribute auth_session_key.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def auth_session_key @auth_session_key end |
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def client_secret @client_secret end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/yiffspace/auth/client.rb', line 12 def name @name end |
#permissions ⇒ Object
Returns the value of attribute permissions.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def @permissions end |
#permissions_separator ⇒ Object
Returns the value of attribute permissions_separator.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def @permissions_separator end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def redirect_uri @redirect_uri end |
#resource ⇒ Object
Returns the value of attribute resource.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def resource @resource end |
#scopes ⇒ Object
Returns the value of attribute scopes.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def scopes @scopes end |
#server_url ⇒ Object
Returns the value of attribute server_url.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def server_url @server_url end |
#update_discord_images ⇒ Object
Returns the value of attribute update_discord_images.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def update_discord_images @update_discord_images end |
#user_session_key ⇒ Object
Returns the value of attribute user_session_key.
8 9 10 |
# File 'lib/yiffspace/auth/client.rb', line 8 def user_session_key @user_session_key end |
Instance Method Details
#logto(controller) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yiffspace/auth/client.rb', line 26 def logto(controller) LogtoClient.new( config: LogtoClient::Config.new( endpoint: server_url, app_id: client_id, app_secret: client_secret, scopes: scopes + , resources: [resource].compact, ), # Allow the client to redirect to other hosts (i.e. your Logto tenant) navigate: ->(uri) { controller.redirect_to(uri, allow_other_host: true) }, # Controller has access to the session object storage: LogtoClient::NamedSessionStorage.new("yiffspace", controller.session, app_id: @name), ) end |