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

Update master-next from master #1361

Merged
merged 83 commits into from Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
5dec97c
fix(prow): updated modal-annotations e2e tests
dtaylor113 Mar 13, 2019
ff0892b
Remove unused tokenInfoModal component
jhadvig Mar 20, 2019
e76db99
Bug 1690799: Remove output ImageStreamTag from BuildConfig YAML template
spadgett Mar 20, 2019
bace429
Bug 1689837 - Should not list cluster scope service bindings when vis…
dtaylor113 Mar 20, 2019
d0e1963
Add console integration tests that better exercise auth
TheRealJon Mar 12, 2019
83f5eee
Improve layout of workload tables
spadgett Mar 18, 2019
4fbc382
Merge pull request #1312 from dtaylor113/service-binding-param-fix
openshift-merge-robot Mar 20, 2019
f931184
Allow the escape key to close blocking modals
spadgett Mar 19, 2019
72917a1
Merge pull request #1293 from TheRealJon/CONSOLE-1288
openshift-merge-robot Mar 20, 2019
f2d9af8
Fix console memory leak
spadgett Mar 20, 2019
9e45f28
Merge pull request #1311 from spadgett/bc-yaml
openshift-merge-robot Mar 20, 2019
0279a92
Merge pull request #1314 from spadgett/esc-close-blocking-modal
openshift-merge-robot Mar 20, 2019
b86de00
Merge pull request #1304 from spadgett/workload-containers-layout
openshift-merge-robot Mar 21, 2019
87a1a3d
uninstall flow from Marketplace
alecmerdler Mar 13, 2019
6da48cb
Merge pull request #1305 from alecmerdler/bugzilla-1686421
openshift-merge-robot Mar 21, 2019
f8e74b6
Merge pull request #1316 from spadgett/memory-leak
openshift-merge-robot Mar 21, 2019
f7586be
auth: reuse HTTP clients if ca.crt hasn't changed
spadgett Mar 21, 2019
69f0353
Merge pull request #1318 from spadgett/reuse-http-client
openshift-merge-robot Mar 21, 2019
963ee6f
Merge pull request #1310 from jhadvig/rm-token-modal
openshift-merge-robot Mar 22, 2019
647fe69
Monitoring: Increase graph padding
kyoto Mar 22, 2019
4cb7470
Merge pull request #1319 from kyoto/query-browser-padding
openshift-merge-robot Mar 22, 2019
c0648fe
Monitoring: Improve graph hover labels to only show those that differ
kyoto Mar 22, 2019
23a123c
Bug 1691694: Avoid runtime error when event reason missing
spadgett Mar 22, 2019
087ae2f
Merge pull request #1321 from kyoto/query-browser-hover-labels
openshift-merge-robot Mar 22, 2019
c0eb1f0
Bug 1633127 - Use SI prefixes in graphs
spadgett Mar 22, 2019
86a2088
Adding co-resource-link__resource-api class and rules so that active …
sg00dwin Mar 22, 2019
7b42082
Merge pull request #1323 from spadgett/chart-units
openshift-merge-robot Mar 22, 2019
41b2f11
Merge pull request #1286 from dtaylor113/test-flakes
openshift-merge-robot Mar 22, 2019
c7d30b3
introduce hack to ensure backwards compatibility with new Marketplace…
alecmerdler Mar 21, 2019
ccf6898
Merge pull request #1322 from spadgett/events-runtime-error
openshift-merge-robot Mar 23, 2019
a1d1903
Merge pull request #1326 from sg00dwin/search-dropdown-menu-api-color
openshift-merge-robot Mar 23, 2019
7bf984f
Merge pull request #1327 from alecmerdler/OLM-978
openshift-merge-robot Mar 23, 2019
61284aa
Monitoring: Enable y axis zoom for alert and alerting rule graphs
kyoto Mar 25, 2019
b354f1f
Monitoring: Use formatPrometheusDuration() for alerting rule's `for`
kyoto Mar 25, 2019
8149b09
Monitoring: Use a default graph span that matches a dropdown option
kyoto Mar 25, 2019
603bc6b
Bug BZ1691602: should hide password when configure default pull secre…
jhadvig Mar 25, 2019
68f1de0
Monitoring: Fix graph time span dropdown to align with the text input
kyoto Mar 25, 2019
dd6252e
Merge pull request #1329 from kyoto/query-browser-yaxis-zoom
openshift-merge-robot Mar 25, 2019
acdb319
Merge pull request #1331 from kyoto/query-browser-default-span
openshift-merge-robot Mar 25, 2019
845e02e
Merge pull request #1333 from jhadvig/BZ1691602
openshift-merge-robot Mar 25, 2019
990e03b
Monitoring: Add Prometheus API timeout option
kyoto Mar 25, 2019
c526df4
Merge pull request #1330 from kyoto/monitoring-for-duration-format
openshift-merge-robot Mar 25, 2019
af2162c
Merge pull request #1334 from kyoto/query-browser-fix-dropdown-alignment
openshift-merge-robot Mar 25, 2019
5c9cec7
Added script to debug unit and e2e tests
dtaylor113 Mar 21, 2019
e884e44
Merge pull request #1317 from dtaylor113/debug-e2e
openshift-merge-robot Mar 25, 2019
039729a
Update console for identity provider API changes
spadgett Mar 25, 2019
79fcd89
Merge pull request #1335 from kyoto/query-browser-timeout
openshift-merge-robot Mar 25, 2019
a37a24d
Fix scenario 'logs in via htpasswd identity provider' for username
xiaocwan Mar 26, 2019
9cc539c
Merge pull request #1338 from xiaocwan/master
openshift-merge-robot Mar 26, 2019
fc80ef3
Add Taints and Tolerations
nicolethoen Mar 4, 2019
14ec354
Monitoring: Use PatternFly input error style for graph span text input
kyoto Mar 26, 2019
932d791
Taints and tolerations clean up
spadgett Mar 26, 2019
faf01b7
Merge pull request #1337 from spadgett/oauth-api-changes
openshift-merge-robot Mar 26, 2019
2f30fd1
Add OpenID IDP Form to Cluster Settings OAuth Page
jcaianirh Mar 23, 2019
6d205f3
Improve OpenID IDP Form
spadgett Mar 26, 2019
3909daa
Commits Squashed
invalid-email-address Mar 27, 2019
2fe9848
Align secrets createItems with deploymentConfig's
jhadvig Mar 27, 2019
77a0773
Merge pull request #1339 from AyushAmbastha/SC-Overview
openshift-merge-robot Mar 27, 2019
625390c
Merge pull request #1328 from jcaianirh/oath_idp
openshift-merge-robot Mar 27, 2019
ec2fd75
Add common component for idp mapping method dropdown
jcaianirh Mar 27, 2019
0b24402
Merge pull request #1301 from nicolethoen/taints_and_toleration
openshift-merge-robot Mar 27, 2019
406aa3c
added 'Deny' button to link to delete Subscription modal
alecmerdler Mar 21, 2019
ff05bdd
Show tolerations in overview resource summaries
spadgett Mar 27, 2019
25ea564
Don't automatically add an empty row to taints and tolerations dialogs
spadgett Mar 27, 2019
7cddd5b
Merge pull request #1343 from alecmerdler/OLM-911
openshift-merge-robot Mar 27, 2019
86ff923
Improve consistency of remove button
spadgett Mar 27, 2019
100c5a1
fixed incorrect patching of CatalogSourceConfig
alecmerdler Mar 25, 2019
0ed2ddb
Merge pull request #1345 from jhadvig/secret-items
openshift-merge-robot Mar 28, 2019
432b4f7
Remove duplication of dropdown items
rhamilto Mar 27, 2019
782814c
Add cluster version flag check for masthead toolbar update icon
TheRealJon Mar 27, 2019
699485e
Update OpenID IDP form
spadgett Mar 28, 2019
1278f53
Merge pull request #1347 from TheRealJon/bug-1683105
openshift-merge-robot Mar 29, 2019
95495e6
Merge pull request #1351 from alecmerdler/CONSOLE-1350
openshift-merge-robot Mar 29, 2019
9093f39
Merge pull request #1352 from rhamilto/masthead-links
openshift-merge-robot Mar 29, 2019
a1aa062
Merge pull request #1353 from spadgett/overview-summary-tolerations
openshift-merge-robot Mar 29, 2019
f5d8a0b
Merge pull request #1354 from spadgett/no-taints-tolerations
openshift-merge-robot Mar 29, 2019
4963def
Merge pull request #1348 from jcaianirh/idp-mapping-method
openshift-merge-robot Mar 29, 2019
5bd3a43
Merge pull request #1356 from spadgett/openid-tweaks
openshift-merge-robot Mar 29, 2019
0afe64e
Merge pull request #1340 from kyoto/query-browser-invalid-span-style
openshift-merge-robot Mar 29, 2019
5a1ac61
Monitoring: Fix Graph's Reset Zoom button to also reset the Y axis
kyoto Mar 28, 2019
f1031f7
Merge pull request #1358 from kyoto/query-browser-yaxis-reset-zoom
openshift-merge-robot Mar 29, 2019
41abbf2
Merge pull request #1355 from spadgett/remove-btn-styles
openshift-merge-robot Mar 29, 2019
2daff4f
Merge branch 'master' of github.com:openshift/console into master-next
rhamilto Mar 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Expand Up @@ -154,7 +154,7 @@ yarn run dev
```
If changes aren't detected, you might need to increase `fs.inotify.max_user_watches`. See <https://webpack.js.org/configuration/watch/#not-enough-watchers>.

### Tests
### Unit Tests

Run all unit tests:
```
Expand All @@ -171,6 +171,14 @@ Run frontend tests:
./test-frontend.sh
```

#### Debugging Unit Tests

1. `cd frontend; yarn run build`
2. Add `debugger;` statements to any unit test
3. `yarn debug-test route-pages`
4. Chrome browser URL: 'chrome://inspect/#devices', click on the 'inspect' link in **Target (v10...)** section.
5. Launches chrome-dev tools, click Resume button to continue
6. Will break on any `debugger;` statements

### Integration Tests

Expand Down Expand Up @@ -222,6 +230,16 @@ $ ./test-gui.sh olm

Remove the `--headless` flag to Chrome (chromeOptions) in [protractor.conf.ts](frontend/integration-tests/protractor.conf.ts) to see what the tests are actually doing.

##### Debugging Integration Tests

1. `cd frontend; yarn run build`
2. Add `debugger;` statements to any e2e test
3. `yarn run debug-test-suite --suite overview`
4. Chrome browser URL: 'chrome://inspect/#devices', click on the 'inspect' link in **Target (v10...)** section.
5. Launches chrome-dev tools, click Resume button to continue
6. Will break on any `debugger;` statements
7. Pauses browser when not using `--headless` argument!

### Dependency Management

Dependencies should be pinned to an exact semver, sha, or git tag (eg, no ^).
Expand Down
66 changes: 51 additions & 15 deletions auth/auth.go
Expand Up @@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"strings"
"sync"
"time"

"github.com/coreos/dex/api"
Expand All @@ -39,15 +40,27 @@ const (
errorInvalidState = "invalid_state"
)

var log = capnslog.NewPackageLogger("github.com/openshift/console", "auth")
var (
log = capnslog.NewPackageLogger("github.com/openshift/console", "auth")

type Authenticator struct {
tokenVerifier func(string) (*loginState, error)
// Cache HTTP clients to avoid recreating them for each request to the
// OAuth server. The key is the ca.crt bytes cast to a string and the
// value is a pointer to the http.Client. Keep two maps: one that
// incldues system roots and one that doesn't.
httpClientCache sync.Map
httpClientCacheSystemRoots sync.Map
)

type Authenticator struct {
authFunc func() (*oauth2.Config, loginMethod)

clientFunc func() *http.Client

// userFunc returns the User associated with the cookie from a request.
// This is not part of loginMethod to avoid creating an unnecessary
// HTTP client for every call.
userFunc func(*http.Request) (*User, error)

errorURL string
successURL string
cookiePath string
Expand All @@ -66,8 +79,6 @@ type loginMethod interface {
login(http.ResponseWriter, *oauth2.Token) (*loginState, error)
// logout deletes any cookies associated with the user.
logout(http.ResponseWriter, *http.Request)
// authenticate fetches the bearer token from the cookie of a request.
authenticate(*http.Request) (*User, error)
// getKubeAdminLogoutURL returns the logout URL for the special
// kube:admin user in OpenShift
getKubeAdminLogoutURL() string
Expand Down Expand Up @@ -112,27 +123,43 @@ func newHTTPClient(issuerCA string, includeSystemRoots bool) (*http.Client, erro
return nil, fmt.Errorf("load issuer CA file %s: %v", issuerCA, err)
}

caKey := string(data)
var certPool *x509.CertPool
if includeSystemRoots {
if httpClient, ok := httpClientCacheSystemRoots.Load(caKey); ok {
return httpClient.(*http.Client), nil
}
certPool, err = x509.SystemCertPool()
if err != nil {
log.Errorf("error copying system cert pool: %v", err)
certPool = x509.NewCertPool()
}
} else {
if httpClient, ok := httpClientCache.Load(caKey); ok {
return httpClient.(*http.Client), nil
}
certPool = x509.NewCertPool()
}
if !certPool.AppendCertsFromPEM(data) {
return nil, fmt.Errorf("file %s contained no CA data", issuerCA)
}
return &http.Client{

httpClient := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
RootCAs: certPool,
},
},
Timeout: time.Second * 5,
}, nil
}

if includeSystemRoots {
httpClientCacheSystemRoots.Store(caKey, httpClient)
} else {
httpClientCache.Store(caKey, httpClient)
}

return httpClient, nil
}

// NewAuthenticator initializes an Authenticator struct. It blocks until the authenticator is
Expand All @@ -154,6 +181,7 @@ func NewAuthenticator(ctx context.Context, c *Config) (*Authenticator, error) {
var authSourceFunc func() (oauth2.Endpoint, loginMethod, error)
switch c.AuthSource {
case AuthSourceOpenShift:
a.userFunc = getOpenShiftUser
authSourceFunc = func() (oauth2.Endpoint, loginMethod, error) {
// Use the k8s CA for OAuth metadata discovery.
// Don't include system roots when talking to the API server.
Expand All @@ -171,14 +199,22 @@ func NewAuthenticator(ctx context.Context, c *Config) (*Authenticator, error) {
})
}
default:
// OIDC auth source is stateful, so only create it once.
endpoint, oidcAuthSource, err := newOIDCAuth(ctx, &oidcConfig{
client: a.clientFunc(),
issuerURL: c.IssuerURL,
clientID: c.ClientID,
cookiePath: c.CookiePath,
secureCookies: c.SecureCookies,
})
a.userFunc = func(r *http.Request) (*User, error) {
if oidcAuthSource == nil {
return nil, fmt.Errorf("OIDC auth source is not intialized")
}
return oidcAuthSource.authenticate(r)
}
authSourceFunc = func() (oauth2.Endpoint, loginMethod, error) {
return newOIDCAuth(ctx, &oidcConfig{
client: a.clientFunc(),
issuerURL: c.IssuerURL,
clientID: c.ClientID,
cookiePath: c.CookiePath,
secureCookies: c.SecureCookies,
})
return endpoint, oidcAuthSource, err
}
}

Expand Down Expand Up @@ -273,7 +309,7 @@ type User struct {
}

func (a *Authenticator) Authenticate(r *http.Request) (*User, error) {
return a.getLoginMethod().authenticate(r)
return a.userFunc(r)
}

// LoginFunc redirects to the OIDC provider for user login.
Expand Down
2 changes: 1 addition & 1 deletion auth/auth_openshift.go
Expand Up @@ -159,7 +159,7 @@ func (o *openShiftAuth) logout(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNoContent)
}

func (o *openShiftAuth) authenticate(r *http.Request) (*User, error) {
func getOpenShiftUser(r *http.Request) (*User, error) {
// TODO: This doesn't do any validation of the cookie with the assumption that the
// API server will reject tokens it doesn't recognize. If we want to keep some backend
// state we should sign this cookie. If not there's not much we can do.
Expand Down
5 changes: 3 additions & 2 deletions frontend/__mocks__/k8sResourcesMocks.ts
Expand Up @@ -9,7 +9,8 @@ import {
CatalogSourceKind,
InstallPlanApproval,
PackageManifestKind,
OperatorGroupKind } from '../public/components/operator-lifecycle-manager';
OperatorGroupKind,
InstallPlanPhase } from '../public/components/operator-lifecycle-manager';
import { StatusCapability, SpecCapability } from '../public/components/operator-lifecycle-manager/descriptors/types';
import { CustomResourceDefinitionKind, K8sResourceKind, K8sKind } from '../public/module/k8s';
/* eslint-enable no-unused-vars */
Expand Down Expand Up @@ -307,7 +308,7 @@ export const testInstallPlan: InstallPlanKind = {
approval: InstallPlanApproval.Automatic,
},
status: {
phase: 'Complete',
phase: InstallPlanPhase.InstallPlanPhaseComplete,
catalogSources: ['test-catalog'],
plan: [],
},
Expand Down
23 changes: 22 additions & 1 deletion frontend/__mocks__/operatorHubItemsMocks.ts
@@ -1,6 +1,7 @@
/* eslint-disable no-unused-vars, no-undef */

import { PackageManifestKind } from '../public/components/operator-lifecycle-manager';
import { OperatorHubItem } from '../public/components/operator-hub';

const amqPackageManifest = {
apiVersion: 'packages.app.redhat.com/v1alpha1',
Expand Down Expand Up @@ -315,6 +316,7 @@ export const operatorHubTileViewPageProps = {
{
obj: amqPackageManifest,
installState: 'Installed',
installed: false,
kind: 'PackageManifest',
name: 'amq-streams',
uid: 'amq-streams/openshift-operator-lifecycle-manager',
Expand All @@ -332,10 +334,13 @@ export const operatorHubTileViewPageProps = {
support: undefined,
longDescription: undefined,
categories: ['messaging', 'streaming'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
{
obj: etcdPackageManifest,
installState: 'Not Installed',
installed: false,
kind: 'PackageManifest',
name: 'etcd',
uid: 'etcd/openshift-operator-lifecycle-manager',
Expand All @@ -353,9 +358,12 @@ export const operatorHubTileViewPageProps = {
support: undefined,
longDescription: undefined,
categories: ['database'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
{ obj: federationv2PackageManifest,
installState: 'Not Installed',
installed: false,
kind: 'PackageManifest',
name: 'federationv2',
uid: 'federationv2/openshift-operator-lifecycle-manager',
Expand All @@ -373,9 +381,12 @@ export const operatorHubTileViewPageProps = {
support: undefined,
longDescription: undefined,
categories: [],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
{ obj: prometheusPackageManifest,
installState: 'Not Installed',
installed: false,
kind: 'PackageManifest',
name: 'prometheus',
uid: 'prometheus/openshift-operator-lifecycle-manager',
Expand All @@ -393,9 +404,12 @@ export const operatorHubTileViewPageProps = {
support: undefined,
longDescription: undefined,
categories: ['monitoring', 'alerting'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
{ obj: svcatPackageManifest,
installState: 'Not Installed',
installed: false,
kind: 'PackageManifest',
name: 'svcat',
uid: 'svcat/openshift-operator-lifecycle-manager',
Expand All @@ -413,8 +427,10 @@ export const operatorHubTileViewPageProps = {
support: undefined,
longDescription: undefined,
categories: ['catalog'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
],
] as OperatorHubItem[],
openOverlay: null,
};

Expand All @@ -427,6 +443,7 @@ export const operatorHubTileViewPagePropsWithDummy = {
operatorHubTileViewPageProps.items[4],
{
obj: dummyPackageManifest,
installed: false,
kind: 'PackageManifest',
name: 'dummy',
uid: 'dummy/openshift-operator-lifecycle-manager',
Expand All @@ -444,6 +461,8 @@ export const operatorHubTileViewPagePropsWithDummy = {
support: undefined,
longDescription: undefined,
categories: ['dummy'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
},
],
openOverlay: null,
Expand Down Expand Up @@ -553,4 +572,6 @@ export const itemWithLongDescription = {
support: undefined,
longDescription: '**Red Hat AMQ Streams** is a massively scalable, distributed, and high performance data streaming platform based on the Apache Kafka project. \nAMQ Streams provides an event streaming backbone that allows microservices and other application components to exchange data with extremely high throughput and low latency.\n\n**The core capabilities include**\n* A pub/sub messaging model, similar to a traditional enterprise messaging system, in which application components publish and consume events to/from an ordered stream\n* The long term, fault-tolerant storage of events\n* The ability for a consumer to replay streams of events\n* The ability to partition topics for horizontal scalability\n\n# Before you start\n\n1. Create AMQ Streams Cluster Roles\n```\n$ oc apply -f http://amq.io/amqstreams/rbac.yaml\n```\n2. Create following bindings\n```\n$ oc adm policy add-cluster-role-to-user strimzi-cluster-operator -z strimzi-cluster-operator --namespace <namespace>\n$ oc adm policy add-cluster-role-to-user strimzi-kafka-broker -z strimzi-cluster-operator --namespace <namespace>\n```',
categories: ['messaging', 'streaming'],
catalogSource: 'testing',
catalogSourceNamespace: 'openshift-marketplace',
};