Class: RackFederatedAuth::Authentication
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- RackFederatedAuth::Authentication
- Defined in:
- lib/rack-federated-auth.rb
Instance Attribute Summary collapse
-
#auth_prefix ⇒ Object
Returns the value of attribute auth_prefix.
-
#auth_scope ⇒ Object
Returns the value of attribute auth_scope.
-
#auth_url ⇒ Object
Returns the value of attribute auth_url.
-
#email_filter ⇒ Object
Returns the value of attribute email_filter.
-
#failure_message ⇒ Object
Returns the value of attribute failure_message.
-
#failure_url ⇒ Object
Returns the value of attribute failure_url.
-
#public_path_regexes ⇒ Object
Returns the value of attribute public_path_regexes.
-
#success_url ⇒ Object
Returns the value of attribute success_url.
Instance Method Summary collapse
-
#initialize(app) {|_self| ... } ⇒ Authentication
constructor
Set up federated authentication.
Constructor Details
#initialize(app) {|_self| ... } ⇒ Authentication
Set up federated authentication
auth_scope is the session key which will be used to check if the user has authenticated. Allows basic role-based authentication email_filter is a regex which a user’s email must match to be authorized failure_message is the text which will be shown to users after failed auth - use it to help them authenticate correctly auth_prefix will be prepended to the OmniAuth urls (callbacks, etc). auth_url determines which auth strategy will be used - see OmniAuth’s docs for more details success_url is the url the user will be redirected to after successful authentication failure_url for failed authentication (or emails that don’t match email_filter)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rack-federated-auth.rb', line 25 def initialize(app) @auth_scope = "authorized" @email_filter = /.*/ @failure_message = "Authentication failed. Click <a href='#{@auth_url}'>here</a> to try again" @auth_prefix = "/auth" @auth_url = nil @success_url = '/' @failure_url = nil @public_path_regexes = [] yield self if block_given? @auth_url ||= "#{@auth_prefix}/google_oauth2" @failure_url ||= "#{@auth_prefix}/failure" super(app) end |
Instance Attribute Details
#auth_prefix ⇒ Object
Returns the value of attribute auth_prefix.
9 10 11 |
# File 'lib/rack-federated-auth.rb', line 9 def auth_prefix @auth_prefix end |
#auth_scope ⇒ Object
Returns the value of attribute auth_scope.
5 6 7 |
# File 'lib/rack-federated-auth.rb', line 5 def auth_scope @auth_scope end |
#auth_url ⇒ Object
Returns the value of attribute auth_url.
10 11 12 |
# File 'lib/rack-federated-auth.rb', line 10 def auth_url @auth_url end |
#email_filter ⇒ Object
Returns the value of attribute email_filter.
6 7 8 |
# File 'lib/rack-federated-auth.rb', line 6 def email_filter @email_filter end |
#failure_message ⇒ Object
Returns the value of attribute failure_message.
7 8 9 |
# File 'lib/rack-federated-auth.rb', line 7 def @failure_message end |
#failure_url ⇒ Object
Returns the value of attribute failure_url.
12 13 14 |
# File 'lib/rack-federated-auth.rb', line 12 def failure_url @failure_url end |
#public_path_regexes ⇒ Object
Returns the value of attribute public_path_regexes.
13 14 15 |
# File 'lib/rack-federated-auth.rb', line 13 def public_path_regexes @public_path_regexes end |
#success_url ⇒ Object
Returns the value of attribute success_url.
11 12 13 |
# File 'lib/rack-federated-auth.rb', line 11 def success_url @success_url end |