Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return decoded_segments #139

Merged
merged 1 commit into from
Mar 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/jwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ def encode(payload, key, algorithm = 'HS256', header_fields = {})
segments.join('.')
end

def decoded_segments(jwt, key = nil, verify = true, custom_options = {}, &keyfinder)
fail(JWT::DecodeError, 'Nil JSON web token') unless jwt

options = {
verify_expiration: true,
verify_not_before: true,
verify_iss: false,
verify_iat: false,
verify_jti: false,
verify_aud: false,
verify_sub: false,
leeway: 0
}

merged_options = options.merge(custom_options)

decoder = Decode.new jwt, key, verify, merged_options, &keyfinder
decoder.decode_segments
end


def decode(jwt, key = nil, verify = true, custom_options = {}, &keyfinder)
fail(JWT::DecodeError, 'Nil JSON web token') unless jwt

Expand Down