Return appropriate controller-access for remote users. #6372

Merged
merged 4 commits into from Oct 5, 2016

Conversation

Projects
None yet
3 participants
Owner

howbazaar commented Oct 4, 2016

This bug addresses two issues:
http://pad.lv/1621679 - Login succeeds when permissions forbid it but all requests are denied afterwards
http://pad.lv/1629089 - API Login ACL response values differ from CLI

The authenticiation code was not adding higher level "everyone" controller access to the login response.
Also, the same area of code would not reject access to a model for an unknown user if there was an "everyone" controller permission.

Tidied up the tests a bit to use test cleanup to close api connections rather than adding a defer call to every test.

Maybe we need to talk a bit more about the group permissions

apiserver/admin.go
+ // It is possible that there isn't a controllerUser for the remote user,
+ // so in that situation, we allows the remote user login access.
+ if permission.LoginAccess.GreaterControllerAccessThan(controllerAccess) {
+ controllerAccess = permission.LoginAccess
@wallyworld

wallyworld Oct 4, 2016

Owner

This doesn't look right. And the new tests seems to confirm that. If a permission has been granted to everyone@external, and then that's what will be used for external users (if greater than explicit permission)
There's already a helper for this apiserver/common/maybeUseGroupPermission()

@wallyworld

wallyworld Oct 4, 2016

Owner

Discussed live: as of now, permissions are expected be defined explicitly, either for the specific user, or via the special "everyone@external" group. So if there is no controller access record for the external user, and there is no "everyone@external" permission to fall back on, then we should return a permission denied. We can loosen that strict approach if needed, but right now it's best to start as restrictive as possible. All the current workflows that I am aware of will work with this strict approach.

apiserver/admin_test.go
+ assertPermissionDenied(c, err)
+}
+
+func (s *loginSuite) loginUserWithAccess(c *gc.C, info *api.Info) (*state.User, params.LoginResult) {
@wallyworld

wallyworld Oct 4, 2016

Owner

what does "WithAccess" mean here?
It seems like it should mean "log in this specified user with this specified access" but that doesn't seem to be the case?

Owner

howbazaar commented Oct 4, 2016

@wallyworld updated the behaviour, extracted into its own function.

apiserver/admin_test.go
c.Check(result.UserInfo.ModelAccess, gc.Equals, "write")
}
+func (s *macaroonLoginSuite) AddControllerUser(c *gc.C, user names.UserTag, access permission.Access) {
@wallyworld

wallyworld Oct 4, 2016

Owner

prefer lower case addControllerUser()

Owner

howbazaar commented Oct 4, 2016

$$merge$$

Contributor

jujubot commented Oct 4, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Oct 4, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9405

Owner

howbazaar commented Oct 5, 2016

$$merge$$

Contributor

jujubot commented Oct 5, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

Contributor

jujubot commented Oct 5, 2016

Build failed: Tests failed
build url: http://juju-ci.vapour.ws:8080/job/github-merge-juju/9409

Owner

howbazaar commented Oct 5, 2016

$$merge$$

Contributor

jujubot commented Oct 5, 2016

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit d068d91 into juju:master Oct 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment