Skip to content

Commit

Permalink
Deprecate :encode option of Bearer auth header
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Jun 23, 2014
1 parent 5f28f22 commit ef9560a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/http/authorization_header/bearer_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ module AuthorizationHeader
class BearerToken
# @param [#fetch] opts
# @option opts [#to_s] :token
# @option opts [#to_s] :encode (false)
# @option opts [Boolean] :encode (false) deprecated
def initialize(opts)
@encode = opts.fetch :encode, false
@token = opts.fetch :token
end
@token = opts.fetch :token

return unless opts.fetch(:encode, false)

def token
return Base64.strict_encode64 @token if @encode
@token
warn "#{Kernel.caller.first}: [DEPRECATION] BearerToken :encode option is deprecated. " \
"You should pass encoded token on your own: { :token => Base64.strict_encode64('token') }"
@token = Base64.strict_encode64 @token
end

# :nodoc:
def to_s
"Bearer #{token}"
"Bearer #{@token}"
end
end

Expand Down

0 comments on commit ef9560a

Please sign in to comment.