Module: Cassette::Authentication::Filter
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cassette/authentication/filter.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #accepts_authentication_service?(service) ⇒ Boolean
- #authentication_service ⇒ Object
- #validate_authentication_ticket(service = authentication_service) ⇒ Object
- #validate_raw_role!(role) ⇒ Object
- #validate_role!(role) ⇒ Object
Instance Method Details
#accepts_authentication_service?(service) ⇒ Boolean
22 23 24 25 26 27 28 29 30 |
# File 'lib/cassette/authentication/filter.rb', line 22 def accepts_authentication_service?(service) config = Cassette.config if config.respond_to?(:services) config.services.member?(service) || config.service == service else config.service == service end end |
#authentication_service ⇒ Object
45 46 47 |
# File 'lib/cassette/authentication/filter.rb', line 45 def authentication_service Cassette.config.service end |
#validate_authentication_ticket(service = authentication_service) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cassette/authentication/filter.rb', line 32 def validate_authentication_ticket(service = authentication_service) ticket = request.headers['Service-Ticket'] || params[:ticket] if ENV['NOAUTH'] Cassette.logger.debug 'NOAUTH set and no Service Ticket, skipping authentication' self.current_user = Cassette::Authentication::User.new return end fail Cassette::Errors::Forbidden unless accepts_authentication_service?(authentication_service) self.current_user = Cassette::Authentication.validate_ticket(ticket, service) end |
#validate_raw_role!(role) ⇒ Object
54 55 56 57 |
# File 'lib/cassette/authentication/filter.rb', line 54 def validate_raw_role!(role) return if ENV['NOAUTH'] fail Cassette::Errors::Forbidden unless current_user.has_raw_role?(role) end |
#validate_role!(role) ⇒ Object
49 50 51 52 |
# File 'lib/cassette/authentication/filter.rb', line 49 def validate_role!(role) return if ENV['NOAUTH'] fail Cassette::Errors::Forbidden unless current_user.has_role?(role) end |