lib/json/jwt.rb in json-jwt-1.9.2 vs lib/json/jwt.rb in json-jwt-1.9.3
- old
+ new
@@ -1,7 +1,7 @@
require 'openssl'
-require 'url_safe_base64'
+require 'base64'
require 'active_support'
require 'active_support/core_ext'
require 'json/jose'
module JSON
@@ -44,28 +44,28 @@
[
header.to_json,
self.to_json,
signature
].collect do |segment|
- UrlSafeBase64.encode64 segment.to_s
+ Base64.urlsafe_encode64 segment.to_s, padding: false
end.join('.')
end
def as_json(options = {})
case options[:syntax]
when :general
{
- payload: UrlSafeBase64.encode64(self.to_json),
+ payload: Base64.urlsafe_encode64(self.to_json, padding: false),
signatures: [{
- protected: UrlSafeBase64.encode64(header.to_json),
- signature: UrlSafeBase64.encode64(signature.to_s)
+ protected: Base64.urlsafe_encode64(header.to_json, padding: false),
+ signature: Base64.urlsafe_encode64(signature.to_s, padding: false)
}]
}
when :flattened
{
- protected: UrlSafeBase64.encode64(header.to_json),
- payload: UrlSafeBase64.encode64(self.to_json),
- signature: UrlSafeBase64.encode64(signature.to_s)
+ protected: Base64.urlsafe_encode64(header.to_json, padding: false),
+ payload: Base64.urlsafe_encode64(self.to_json, padding: false),
+ signature: Base64.urlsafe_encode64(signature.to_s, padding: false)
}
else
super
end
end