Sha256: ec9b65ed8105a97174f58dbd4e3ca3ee5856a9b558b3360a39fa435a1cf213b7
Contents?: true
Size: 828 Bytes
Versions: 2
Compression:
Stored size: 828 Bytes
Contents
require 'cabal/api/common/services' module Cabal module API module Common module Authenticated def self.included(base) base.class_eval do include Cabal::API::Common::Services helpers do def current_user authorization = headers['Authorization'].to_s access_key, signature = authorization.split(':') user = user_service.by_access_key(access_key) if user && user.authenticated_with?(signature) user else nil end end def authenticate! error!({message: 'Unauthorized.'}, 401) unless current_user end end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cabal-api-0.2.4 | lib/cabal/api/common/authenticated.rb |
cabal-api-0.2.3 | lib/cabal/api/common/authenticated.rb |