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

Add requireAdmin() to Sync Function (Fixes #3276) #3277

Merged
merged 1 commit into from
Apr 12, 2018

Conversation

JFlath
Copy link
Contributor

@JFlath JFlath commented Feb 6, 2018

Fixes #3276 This adds a new callback to the Sync Function:

requireAdmin();

This allows rejecting mutations that don't come via the Admin port.

@hideki hideki added the review label Feb 6, 2018
runner, err := NewSyncRunner(funcSource)
assert.Equals(t, err, nil)
var result interface{}
result, _ = runner.Call(parse(`{}`), parse(`{}`), parse(`{}`))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, this is equivalent to how a request from the Admin port will hit the Sync Function, but would appreciate a double-check on this.

assertNotRejected(t, result)
result, _ = runner.Call(parse(`{}`), parse(`{}`), parse(`{"name": ""}`))
assertRejected(t, result, base.HTTPErrorf(403, "admin required"))
result, _ = runner.Call(parse(`{}`), parse(`{}`), parse(`{"name": "GUEST"}`))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, AFAIK this should represent a request as the GUEST user, but a double-check of my logic here would be good.

@JFlath JFlath changed the base branch from master to dev February 6, 2018 13:00
@JFlath JFlath force-pushed the feature/issue_3276 branch 2 times, most recently from 31d869b to 23e772a Compare February 6, 2018 13:12
Copy link
Member

@bbrks bbrks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know enough about how the runner gets called to verify your comments, so I'll wait for Adam or Traun to review, but in looks good in general 👍

@adamcfraser
Copy link
Collaborator

@JFlath This looks good to me, but it looks like it pulled in an unnecessary manifest change somewhere along the way. Do you mind rebasing to get rid of that, then ping me and I can merge?

@JFlath
Copy link
Contributor Author

JFlath commented Apr 2, 2018

Hey, when I tried the first time, I think I pulled in 200-odd commits, it's an improvement 😂! Will sort it out when I get a sec, thanks!

@JFlath JFlath changed the base branch from dev to master April 12, 2018 00:09
Copy link
Collaborator

@adamcfraser adamcfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Sanity checked against a local SG and everything works as advertised.

@adamcfraser adamcfraser merged commit b7d3db9 into master Apr 12, 2018
@adamcfraser adamcfraser deleted the feature/issue_3276 branch April 12, 2018 22:01
@JFlath
Copy link
Contributor Author

JFlath commented Apr 12, 2018

/me adds Golang to LinkedIn skills

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.

4 participants