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

Conditionally deny access to web console #4046

Merged
merged 7 commits into from Aug 12, 2015

Conversation

miminar
Copy link

@miminar miminar commented Aug 7, 2015

If the web console component is disabled through masterConfig.DisabledFeatures, deny all the access to:

  • $MASTER_URL/console
  • $MASTER_URL/console/*

And prevent http server for static assets from running.

Signed-off-by: Michal Minar miminar@redhat.com

@liggitt
Copy link
Contributor

liggitt commented Aug 7, 2015

Auth is needed for OAuth and CLI login. Only disable the asset bits

@@ -22,6 +22,10 @@ import (
// then returns an array of strings indicating what endpoints were started
// (these are format strings that will expect to be sent a single string value).
func (c *AssetConfig) InstallAPI(container *restful.Container) []string {
if c.WebConsoleDisabled {
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't belong here... just skip building the AssetConfig entirely if web console is disabled

@miminar
Copy link
Author

miminar commented Aug 7, 2015

Thanks @liggitt, rework has just started.

@miminar
Copy link
Author

miminar commented Aug 7, 2015

Haven't touched the authentication part yet. Need to investigate a bit further. CLI login works with Web Console disabled (tested with default AllowAllPasswordIdentityProvider and HTPasswdPasswordIdentityProvider). @ashcrow any ideas?

TODO: write some tests.

Update: Access to /console gives me following with disabled Web Console:

{
    "kind": "Status",
    "apiVersion": "v1",
    "metadata": {},
    "status": "Failure",
    "message": "User \"system:anonymous\" cannot \"get\" on \"/console\"",
    "reason": "Forbidden",
    "details": {},
    "code": 403
}

Looks unfriendly to me.

@liggitt
Copy link
Contributor

liggitt commented Aug 7, 2015

cli uses the challengers["login"] portion, but other, non-web-console clients could use the browser login

@liggitt
Copy link
Contributor

liggitt commented Aug 7, 2015

e.g. https://master.example.com:8443/oauth/token/request, which is needed in order to get a token for the CLI if an identity provider that doesn't support challenge headers is configured

@liggitt liggitt self-assigned this Aug 7, 2015
@@ -72,6 +73,7 @@ func BuildAuthConfig(options configapi.MasterConfig) (*AuthConfig, error) {
ret := &AuthConfig{
Options: *options.OAuthConfig,

WebConsoleDisabled: options.DisabledFeatures.Has(configapi.FeatureWebConsole),
Copy link
Contributor

Choose a reason for hiding this comment

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

remove this... the only difference the web console being disabled should make to auth is that assetPublicURLs be empty

If the web console component is disabled through `FeatureConfig`, deny
all the access to it.

Signed-off-by: Michal Minar <miminar@redhat.com>
@miminar
Copy link
Author

miminar commented Aug 10, 2015

Rebased, reverted auth part and added simple tests. @liggitt, is it any better now?

@@ -253,6 +241,10 @@ oc get services
mv ${HOME}/.kube/config ${HOME}/.kube/non-default-config
echo "config files: ok"

# Test access to /console/
$(which curl) -sfL --max-time 5 "${API_SCHEME}://${API_HOST}:${API_PORT}/console/" | grep '<title>'
Copy link
Contributor

Choose a reason for hiding this comment

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

won't this fail with cert errors?

Copy link
Author

Choose a reason for hiding this comment

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

CURL_* variables are set above.

@liggitt
Copy link
Contributor

liggitt commented Aug 10, 2015

looks a lot cleaner, a good integration test and we should be ok

@liggitt
Copy link
Contributor

liggitt commented Aug 10, 2015

update the PR title and description with the updated content

@miminar miminar changed the title Deny access to Web Console Conditionally deny access to web console Aug 11, 2015
@miminar
Copy link
Author

miminar commented Aug 11, 2015

@liggitt Added integration test. I'm concerned about /login endpoint though. I get standard login page in browser and after successful login, empty page is received.

}
if resp.Header.Get("Location") != masterConfig.AssetConfig.PublicURL {
t.Errorf("Expected %s, got %s", masterConfig.AssetConfig.PublicURL, resp.Header.Get("Location"))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should also GET the asset public URL to make sure the UI is served

@@ -428,6 +428,10 @@ func (c *MasterConfig) RouteAllocatorClients() (*osclient.Client, *kclient.Clien
return c.PrivilegedLoopbackOpenShiftClient, c.PrivilegedLoopbackKubernetesClient
}

func (c *MasterConfig) WebConsoleEnabled() bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

godoc, since the two conditions aren't obvious from the name of the function

Michal Minar added 2 commits August 11, 2015 17:39
Signed-off-by: Michal Minar <miminar@redhat.com>
Signed-off-by: Michal Minar <miminar@redhat.com>
@miminar
Copy link
Author

miminar commented Aug 11, 2015

@liggitt could you take one more look?

Signed-off-by: Michal Minar <miminar@redhat.com>
if resp.StatusCode != expectedStatus {
t.Errorf("Expected status %d for %s, got %d", expectedStatus, url, resp.StatusCode)
} else {
if expectedRedirectLocation != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be in an else

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, the check shouldn't even be conditional... if we expect "", and get "foo", that's an error

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Signed-off-by: Michal Minar <miminar@redhat.com>
}{
"": {http.StatusFound, masterOptions.AssetConfig.PublicURL},
"healthz": {http.StatusOK, ""},
"login": {http.StatusOK, ""},
Copy link
Contributor

Choose a reason for hiding this comment

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

add "oauth/token/request" expecting a redirect to "oauth/authorize?..." to make sure OAuth is still hooked up

Copy link
Author

Choose a reason for hiding this comment

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

Added, good suggestions.

@liggitt
Copy link
Contributor

liggitt commented Aug 12, 2015

a couple last checks for OAuth, then LGTM

Signed-off-by: Michal Minar <miminar@redhat.com>
@miminar
Copy link
Author

miminar commented Aug 12, 2015

@liggitt another ping :)

@liggitt
Copy link
Contributor

liggitt commented Aug 12, 2015

LGTM, [merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/2940/) (Image: devenv-fedora_2147)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 70af553

@openshift-bot
Copy link
Contributor

[Test]ing while waiting on the merge queue

@miminar
Copy link
Author

miminar commented Aug 12, 2015

@liggitt Thanks!

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/4040/)

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 70af553

openshift-bot pushed a commit that referenced this pull request Aug 12, 2015
@openshift-bot openshift-bot merged commit 0b8fbcb into openshift:master Aug 12, 2015
@stevekuznetsov
Copy link
Contributor

@miminar @liggitt This test may not have ever been run, incorrect build tags: !no-etcd is etcd, no-etcd is !etcd.

@miminar
Copy link
Author

miminar commented Aug 20, 2015

@stevekuznetsov actually the tests run just fine. The problem is they can't be disabled :-). Adding no-etcd to tags doesn't help. There's another integration test file having this tag. I'll remove it.

Update: Looks like you've already taken care of it :-)

@stevekuznetsov
Copy link
Contributor

@miminar Yes, interestingly enough the logic for running tests did run yours. All is well.

@miminar miminar deleted the disable-web-console branch January 24, 2016 18:46
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

5 participants