cmd/modelcmd: support JUJU_USER_DOMAIN #6862

Merged
merged 1 commit into from Jan 24, 2017

Conversation

Projects
None yet
4 participants
Owner

rogpeppe commented Jan 24, 2017

This can be used to select an alternative authentication
domain when authenticating using an external identity
manager.

We also clean up the tests a little by using IsolationSuite
instead of the deprecated FakeJujuXDGDataHomeSuite,
and unexport some fields from APIContext that aren't
used.

@rogpeppe rogpeppe changed the base branch from develop to user-domain Jan 24, 2017

LGTM

cmd/modelcmd/apicontext.go
+}
+
+// Cookies implements http.CookieJar.Cookies by
+// adding the
@mhilton

mhilton Jan 24, 2017

Member

please finish this sentence.

cmd/modelcmd/apicontext.go
+ Jar CookieJar
+ // jar holds the internal version of the cookie jar - it has
+ // methods that clients should not use, such as Save.
+ jar *domainCookieJar
@jameinel

jameinel Jan 24, 2017

Owner

having a member "Jar" and another member "jar" sounds like a huge chance to make mistakes in using the right one.
Can we clarify these more with something like 'domainJar' at least?
I'm not sure why one is exported and one isn't, and comments like
"we send it to everyone because we don't know who needs it", feels very much like a security hole.

@rogpeppe

rogpeppe Jan 24, 2017

Owner

They're actually the same object. The exported one is an interface type so that we can hide methods that we don't want external packages to invoke. Because they're the same object, it doesn't really matter which one is used, so ISTM that using a similar name is OK.

I could rename jar to internalJar if you'd prefer.

"we send it to everyone because we don't know who needs it", feels very much like a security hole.

Can you think of any actual security hole that might result from sending our preferred authentication domain to the parties that we make HTTP requests to?

I guess it might be possible to add a hook to the bakery package so that we could add the cookie only when discharging, but at the moment that seems like more complexity than is warranted.

@rogpeppe

rogpeppe Jan 24, 2017

Owner

OK, I've removed the Jar field and replaced it with a CookieJar method that returns the internal jar implementation, so there's no possibility of them getting out of step.

cmd/modelcmd/apicontext.go
return &APIContext{
Jar: jar,
- WebPageVisitor: webPageVisitor,
+ jar: jar,
@jameinel

jameinel Jan 24, 2017

Owner

things like this where they are subtly the same jar, except when they won't be

@rogpeppe

rogpeppe Jan 24, 2017

Owner

When won't they be the same jar?

@jameinel

jameinel Jan 24, 2017

Owner

this is the sort of "they're never different until someone doesn't understand the code and sets one without setting the other one".

cmd/modelcmd: support JUJU_USER_DOMAIN
This can be used to select an alternative authentication
domain when authenticating using an external identity
manager.

We also clean up the tests a little by using IsolationSuite
instead of the deprecated FakeJujuXDGDataHomeSuite,
and unexport some fields from APIContext that aren't
used.

LGTM

Owner

rogpeppe commented Jan 24, 2017

$$merge$$

Contributor

jujubot commented Jan 24, 2017

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

Contributor

jujubot commented Jan 24, 2017

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

Owner

rogpeppe commented Jan 24, 2017

$$merge$$

Contributor

jujubot commented Jan 24, 2017

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

@jujubot jujubot merged commit ed5aa57 into juju:user-domain Jan 24, 2017

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