-
Notifications
You must be signed in to change notification settings - Fork 121
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
signing with purpose via :for option #20
Conversation
private | ||
def verify(sgid, purpose) | ||
gid, parsed_purpose = verifier.verify(sgid) | ||
raise InvalidPurpose, "Not a valid purpose." unless purpose == parsed_purpose |
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.
I'm not sure if raising an error like this is better than just returning nil for parse
method..
76f5750
to
69fbce6
Compare
Rebased and solved the conflicts. |
verifier.verify(sgid) | ||
def verify(sgid, options) | ||
gid, parsed_purpose = pick_verifier(options).verify(sgid) | ||
raise InvalidPurpose, "Not a valid purpose." unless options[:for] == parsed_purpose |
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.
raise PurposeMismatch, "Expected a Global ID signed for #{options[:for].inspect}, got one signed for #{parsed_purpose.inspect}"
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.
This method is expected to return nil
when the Global ID couldn't be verified, too. So let's skip the new exception for now and just return the gid if <purpose matches?>
@jeremy I've fixed things except the default purpose problem and override the |
sgid = Person.new.sgid(verifier: verifier) | ||
found = GlobalID::Locator.locate_signed(sgid.to_s, verifier: verifier) | ||
assert_kind_of sgid.model_class, found | ||
assert_equal sgid.model_id, found.id |
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.
@jeremy Adding a default purpose will break this test for default serializer can't parse and array.So the test is ugly.Can we modify our default serializer to support parsing for array?
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.
Yeah - that makes sense. Could change it to JSON.
b7e1a9e
to
58048f9
Compare
@jeremy Done with changing the serializer |
Great! Could you rebase & squash commits? |
58048f9
to
b6f5f8b
Compare
@jeremy Done. |
@tony612 sorry, needs rebase again! 馃榿 |
override == in SignedGlobalID to consider purpose change serializer to JSON and clear the tests
b6f5f8b
to
a798022
Compare
@jeremy Just noticed that, but now it's OK again. 馃槂 |
signing with purpose via :for option
Work on #8
There're many
options
everywhere 馃槄 But it seems hard to avoid them..But I have some questions, so I hope to get some of your help 馃槂 @jeremy .I'll comment on the code