-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 localhost:9000 as a redirect URL #10895
add localhost:9000 as a redirect URL #10895
Conversation
@@ -45,6 +46,9 @@ const ( | |||
initialProjectDisplay = "My Project" | |||
initialProjectDesc = "Initial developer project" | |||
|
|||
defaultRedirectClient = "oauthclient/openshift-web-console" |
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.
@fabianofranz
Although I could use the const OpenShiftWebConsoleClientID
defined in pkg/cmd/server/origin/auth.go, I did not want to import server packages, but WDYT?
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.
Hrm, yeah, that could result in bringing to oc
packages that don't belong here (master.go for example imports a lot of server-side stuff).
cc @liggitt |
@juanvallejo we currently update the config here: My preference would be to change it there rather than executing a separate patch command. |
It's not a server config update, it's an update of the API object |
ahh got it, thx @liggitt. @juanvallejo please ignore me and carry on :) |
:) Thanks for the feedback! |
d5e389c
to
5a80c23
Compare
[test] |
return err | ||
} | ||
|
||
patch := fmt.Sprintf("{%q:[%q]}", "redirectURIs", defaultRedirectURI) |
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.
raises eyebrow... this should really be built by json-serializing a struct
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.
actually, why not use the go client to make the call?
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.
actually, why not use the go client to make the call?
Hm, I am not sure what you mean. I thought NewCmdPatch
was already using the client to make the remote call?
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.
@juanvallejo i mean not invoking the command, simply doing a client get and then an update call with your change.
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.
@csrwng Okay, updated to not using NewCmdPatch
, PTAL
5e787cd
to
4b07d66
Compare
@juanvallejo actually that's not what I had in mind :) client, _, err := c.Clients()
webConsoleOAuth, err := client.OAuthClients().Get("openshift-web-console")
// not shown here... check first and don't add it if it's already there
webConsoleOAuth.RedirectURIs = append(webConsoleOAuth.RedirectURIs, "http://localhost:9000")
err = client.OAuthClients().Update(webConsoleOAuth) However, I realized that there's no Update method on the client for OAuthClients (you could add one of course)... @liggitt was that left out on purpose? |
nope |
@csrwng Thanks for the feedback!
I have gone ahead and added an |
no, make Update do an update. look at the other Update client methods and model after that. just Get, add the redirectURI, and Update |
@juanvallejo All you need to do for the update implementation is to do a put. For examples, you can see how other object updates are implemented: |
@@ -17,6 +17,7 @@ type OAuthClientInterface interface { | |||
Get(name string) (*oauthapi.OAuthClient, error) | |||
Delete(name string) error | |||
Watch(opts kapi.ListOptions) (watch.Interface, error) | |||
Update(client *oauthapi.OAuthClient) (*oauthapi.OAuthClient, error) |
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.
need to update fake_oauthclient.go to implement this as well
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.
will do, thanks!
d99ce99
to
dec1b11
Compare
LGTM after a squash |
dec1b11
to
0bed3c0
Compare
re[test] |
conformance test flaked on #9548 re[test] |
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.
a couple nits on names and messages. once updated, this can go ahead and merge... it doesn't need to wait for #10819
@@ -45,6 +46,9 @@ const ( | |||
initialProjectDisplay = "My Project" | |||
initialProjectDesc = "Initial developer project" | |||
|
|||
defaultRedirectClient = "openshift-web-console" | |||
defaultRedirectURI = "https://localhost:9000" |
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.
nit: this isn't the default redirect URI, it's an additional allowed one... more a "developmentRedirectURI"
return nil | ||
} | ||
|
||
webConsoleOAuth, err := oc.OAuthClients().Get(defaultRedirectClient) |
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.
if the web console OAuth client doesn't exist, I would exit early, rather than error
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.
if NotFound, return nil, otherwise, return err
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.
@liggitt Thanks for clarifying! Updated to check if err
is kerrors.IsNotFound
if err != nil { | ||
// announce error without interrupting remaining tasks | ||
suggestedCmd := fmt.Sprintf("oc patch %s -p '{%q:[%q]}'", "oauthclient/openshift-web-console", "redirectURIs", defaultRedirectURI) | ||
errMsg := fmt.Sprintf("Unable to set %q as a default redirect URL for the web console.\nTo manually add it, run %q\n", defaultRedirectURI, suggestedCmd) |
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.
"unable to add development redirect URI to the openshift-web-console OAuthClient..."
0bed3c0
to
2367bcb
Compare
@liggitt Addressed review comments, PTAL |
f89f0ca
to
596047f
Compare
fmt.Fprintf(out, "Unable to find OAuthClient %q\n", defaultRedirectClient) | ||
return nil | ||
} | ||
return err |
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.
if we tolerate an update failure (below), we should probably tolerate a fetch failure as well (not return the error), and print out the same suggestion
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.
@liggitt Sounds good, it no longer returns the err
but rather prints a slightly updated suggestion and returns nil
596047f
to
056b1ce
Compare
LGTM |
Fixes: openshift#10885 This patch adds `https://localhost:9000` as a default redirect URI to the webconsole oauthclient. This is done as a new `oc cluster up` startup task. ``` $ oc cluster up ... -- Finding server IP ... Using <IP> as the server IP -- Starting OpenShift container ... Creating initial OpenShift configuration Starting OpenShift using container 'origin' Waiting for API server to start listening OpenShift server started -- Adding default oAuthClient redirect URIs ... "openshift-web-console" patched -- Installing registry ... OK -- Installing router ... OK -- Importing image streams ... OK -- Importing templates ... OK -- Login to server ... OK -- Creating initial project "myproject" ... OK ... ``` ``` $ oc login -u system:admin $ oc get oauthclients NAME WWW-CHALLENGE REDIRECT URIS openshift-web-console FALSE https://localhost:9000 ```
056b1ce
to
b183604
Compare
[test] |
Evaluated for origin test up to b183604 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9324/) |
[merge] |
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/9324/) (Image: devenv-rhel7_5084) |
Evaluated for origin merge up to b183604 |
Maybe I missed this - why is "localhost" the correct value? |
Won't localhost be wrong if my docker daemon isn't running on my system? |
this is enabling web console development ( |
Can you add some Godoc to this, because nothing in here makes it obvious why it's localhost:9000, and so it's really for a very specific audience, so that usually requires some justification in the code so other people don't remove it. |
Spawned from: openshift#10895 (comment) This patch adds a brief explanation for the use of "localhost:9000" as a default develppment redirect URI in the `oc cluster up` setup.
@smarterclayton I was not sure if making a new pull request was the way I should do this, but please take a look: #11123 |
Spawned from: openshift#10895 (comment) This patch adds a brief explanation for the use of "localhost:9000" as a default develppment redirect URI in the `oc cluster up` setup.
Spawned from: openshift#10895 (comment) This patch adds a brief explanation for the use of "localhost:9000" as a default develppment redirect URI in the `oc cluster up` setup.
Depends on: #10819
Fixes: #10885
This patch adds
https://localhost:9000
as a default redirect URI tothe webconsole oauthclient. This is done as a new
oc cluster up
startup task.
cc @fabianofranz @jwforres @csrwng