Module: Cassette::Authentication::Filter

Extended by:
ActiveSupport::Concern
Defined in:
lib/cassette/authentication/filter.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#validate_authentication_ticket(service = Cassette.config.service) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cassette/authentication/filter.rb', line 20

def validate_authentication_ticket(service = Cassette.config.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

  self.current_user = Cassette::Authentication.validate_ticket(ticket, service)
end

#validate_raw_role!(role) ⇒ Object



37
38
39
40
# File 'lib/cassette/authentication/filter.rb', line 37

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



32
33
34
35
# File 'lib/cassette/authentication/filter.rb', line 32

def validate_role!(role)
  return if ENV['NOAUTH']
  fail Cassette::Errors::Forbidden unless current_user.has_role?(role)
end