Module: AuthenticationHelpers

Defined in:
lib/trogdir/helpers/authentication_helpers.rb

Instance Method Summary collapse

Instance Method Details

#authentic?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/trogdir/helpers/authentication_helpers.rb', line 11

def authentic?
  secret_key = current_syncinator.try(:secret_key)

  ApiAuth.authentic? rack_request, secret_key
end

#authenticate!Object



17
18
19
# File 'lib/trogdir/helpers/authentication_helpers.rb', line 17

def authenticate!
   unauthorized! unless authentic?
end

#current_syncinatorObject



6
7
8
9
# File 'lib/trogdir/helpers/authentication_helpers.rb', line 6

def current_syncinator
  access_id = ApiAuth.access_id(rack_request)
  Syncinator.where(access_id: access_id).first
end

#rack_requestObject



2
3
4
# File 'lib/trogdir/helpers/authentication_helpers.rb', line 2

def rack_request
  Rack::Request.new(@env)
end

#unauthorized!Object



21
22
23
# File 'lib/trogdir/helpers/authentication_helpers.rb', line 21

def unauthorized!
  error!('401 Unauthorized', 401)
end