Sha256: 671e5bdce36c4f2fcb43333ebce2d08fbe83d40ad76b3bae20c7da1a69144dd0
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'g5_authenticatable_api/services/token_info' module G5AuthenticatableApi module Services class TokenValidator < TokenInfo attr_reader :error def validate! begin token_data unless skip_validation? rescue StandardError => @error raise error end end def valid? begin validate! true rescue StandardError => e false end end def auth_response_header if error auth_header = "Bearer" if access_token auth_header << " error=\"#{error_code}\"" auth_header << ",error_description=\"#{error_description}\"" if error_description end auth_header end end private def error_code error_code = error.code if error.respond_to?(:code) error_code || 'invalid_request' end def error_description error_description = error.description if error.respond_to?(:description) error_description end def skip_validation? @warden.try(:user) && !G5AuthenticatableApi.strict_token_validation end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
g5_authenticatable_api-0.4.1 | lib/g5_authenticatable_api/services/token_validator.rb |
g5_authenticatable_api-0.4.0 | lib/g5_authenticatable_api/services/token_validator.rb |