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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

signing with purpose via :for option #20

Merged
merged 1 commit into from
Aug 22, 2014

Conversation

tony612
Copy link
Contributor

@tony612 tony612 commented Aug 19, 2014

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

private
def verify(sgid, purpose)
gid, parsed_purpose = verifier.verify(sgid)
raise InvalidPurpose, "Not a valid purpose." unless purpose == parsed_purpose
Copy link
Contributor Author

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..

@tony612
Copy link
Contributor Author

tony612 commented Aug 20, 2014

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
Copy link
Member

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}"

Copy link
Member

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?>

@tony612
Copy link
Contributor Author

tony612 commented Aug 20, 2014

@jeremy I've fixed things except the default purpose problem and override the == method.

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
Copy link
Contributor Author

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?

Copy link
Member

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.

@tony612
Copy link
Contributor Author

tony612 commented Aug 21, 2014

@jeremy Done with changing the serializer

@jeremy
Copy link
Member

jeremy commented Aug 21, 2014

Great! Could you rebase & squash commits?

@tony612
Copy link
Contributor Author

tony612 commented Aug 21, 2014

@jeremy Done.

@jeremy
Copy link
Member

jeremy commented Aug 21, 2014

@tony612 sorry, needs rebase again! 馃榿

override == in SignedGlobalID to consider purpose

change serializer to JSON and clear the tests
@tony612
Copy link
Contributor Author

tony612 commented Aug 21, 2014

@jeremy Just noticed that, but now it's OK again. 馃槂

jeremy added a commit that referenced this pull request Aug 22, 2014
signing with purpose via :for option
@jeremy jeremy merged commit b94156d into rails:master Aug 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants