-
Notifications
You must be signed in to change notification settings - Fork 376
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
First idea of a extendable JWT decoder #434
Conversation
@@ -0,0 +1,26 @@ | |||
module JWT | |||
module Extension | |||
module ClassMethods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::Extension::ClassMethods has no descriptive comment
true, | ||
create_decode_options(options)).decode_segments | ||
{ | ||
header: segments.last, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::Extension::ClassMethods#decode refers to 'segments' more than self (maybe move it to another class?)
end | ||
|
||
def decode_and_parse_payload(raw_payload) | ||
raw_payload = @options[:decode_payload_proc].call(header, raw_payload, signature) if @options[:decode_payload_proc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::Decode#decode_and_parse_payload calls '@options[:decode_payload_proc]' 2 times
SourceLevel has finished reviewing this Pull Request and has found:
|
An idea of how custom decoding/encoding of an JWT token could be handled. Related to #428
Was thinking that custom decode modules could be created by including the JWT module into them. This included module could then provide a set of DSL methods where different handlers could be defined. For example:
This approach would also make defining keyfinders and such much more elegant than passing everything to the
::JWT.decode
methodIn this PR only a super simple
decode_payload
logic has been implemented as an illustration how it could work.