Skip to content

Commit

Permalink
Merge pull request #538 from SUSE/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
nwmac authored Nov 10, 2020
2 parents 8e87e94 + 24f6580 commit 2090d3c
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 48 deletions.
2 changes: 1 addition & 1 deletion deploy/ci/build-aio-image-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource_types:
- name: stratos-git-resource
type: docker-image
source:
repository: splatform/stratos-git-tag-resource
repository: ghcr.io/cf-stratos/stratos-git-tag-resource

resources:
# Stratos Git Repository
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/build-aio-image-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resource_types:
- name: stratos-git-resource
type: docker-image
source:
repository: splatform/stratos-git-tag-resource
repository: ghcr.io/cf-stratos/stratos-git-tag-resource

resources:
# Stratos Git Repository
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/build-aio-image-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ resource_types:
- name: stratos-git-resource
type: docker-image
source:
repository: splatform/stratos-git-tag-resource
repository: ghcr.io/cf-stratos/stratos-git-tag-resource

resources:
# Stratos Git Repository
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/console-make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource_types:
- name: stratos-git-resource
type: docker-image
source:
repository: splatform/stratos-git-tag-resource
repository: ghcr.io/cf-stratos/stratos-git-tag-resource
resources:
# Stratos Git Repository
- name: stratos
Expand Down
4 changes: 2 additions & 2 deletions deploy/ci/scripts/Dockerfile.stratos-ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Publihsed as splatform/stratos-ci-concourse
# Published as ghcr.io/cf-stratos/stratos-ci-concourse

# Use:
# docker build -f Dockerfile.stratos-ci . -t splatform/stratos-ci-concourse:latest
# docker build -f Dockerfile.stratos-ci . -t ghcr.io/cf-stratos/stratos-ci-concourse:latest

# Default Image used to run tasks - contains Helm

Expand Down
4 changes: 2 additions & 2 deletions deploy/ci/scripts/build-git-tag-resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ chmod +x ./git-resource/assets/check
echo "#!/bin/bash" > ./git-resource/test/all.sh
echo "#!/bin/bash" > ./git-resource/integration-tests/integration.sh

docker build ./git-resource -t splatform/stratos-git-tag-resource:latest
docker push splatform/stratos-git-tag-resource:latest
docker build ./git-resource -t ghcr.io/cf-stratos/stratos-git-tag-resource:latest
docker push ghcr.io/cf-stratos/stratos-git-tag-resource:latest
rm -rf ./tmp
echo "All done"
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/check-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: sh
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/check-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: sh
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/create-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: sh
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/create-helm-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse
params:
GIT_USER:
GIT_EMAIL:
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/create-nightly-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: bash
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/generate-tag-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: bash
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/make-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse
run:
path: sh
args:
Expand Down
2 changes: 1 addition & 1 deletion deploy/ci/tasks/dev-releases/update-gh-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ image_resource:
type: docker-image
source:
# Generated using scripts/Dockerfile.stratos-ci
repository: splatform/stratos-ci-concourse
repository: ghcr.io/cf-stratos/stratos-ci-concourse

run:
path: sh
Expand Down
6 changes: 6 additions & 0 deletions deploy/kubernetes/console/templates/analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ metadata:
app.kubernetes.io/component: "stratos-analyzers"
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app.kubernetes.io/name: "stratos"
Expand Down
7 changes: 5 additions & 2 deletions src/jetstream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -957,8 +957,11 @@ func (p *portalProxy) registerRoutes(e *echo.Echo, needSetupMiddleware bool) {

staticDir, staticDirErr := getStaticFiles(p.Env().String("UI_PATH", "./ui"))

api := e.Group("/api")
api.Use(p.setSecureCacheContentMiddleware)

// Verify Session
e.GET("/api/v1/auth/verify", p.verifySession)
api.GET("/v1/auth/verify", p.verifySession)

// Always serve the backend API from /pp
pp := e.Group("/pp")
Expand Down Expand Up @@ -1010,7 +1013,7 @@ func (p *portalProxy) registerRoutes(e *echo.Echo, needSetupMiddleware bool) {
apiKeyGroupConfig := MiddlewareConfig{Skipper: p.apiKeySkipper}

// API endpoints with Swagger documentation and accessible with an API key
stableAPIGroup := e.Group("/api/v1")
stableAPIGroup := api.Group("/v1")
stableAPIGroup.Use(p.apiKeyMiddleware)
stableAPIGroup.Use(p.sessionMiddlewareWithConfig(apiKeyGroupConfig))
stableAPIGroup.Use(p.xsrfMiddlewareWithConfig(apiKeyGroupConfig))
Expand Down
14 changes: 0 additions & 14 deletions src/jetstream/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ const cfSessionCookieName = "JSESSIONID"
// Header to communicate the configured Cookie Domain
const StratosDomainHeader = "x-stratos-domain"

// Header to communicate whether SSO Login is enabled and if so, any configured options
const StratosSSOHeader = "x-stratos-sso-login"

// Header to communicate any error during SSO
const StratosSSOErrorHeader = "x-stratos-sso-error"

Expand All @@ -42,17 +39,6 @@ const APIKeyAuthScheme = "Bearer"
func handleSessionError(config interfaces.PortalConfig, c echo.Context, err error, doNotLog bool, msg string) error {
log.Debug("handleSessionError")

// Add header so front-end knows SSO login is enabled
if config.SSOLogin {
// A non-empty SSO Header means SSO is enabled
// Use the string "enabled" or send the options string if we have one
options := "enabled"
if len(config.SSOOptions) > 0 {
options = config.SSOOptions
}
c.Response().Header().Set(StratosSSOHeader, options)
}

if strings.Contains(err.Error(), "dial tcp") {
return interfaces.NewHTTPShadowError(
http.StatusServiceUnavailable,
Expand Down
38 changes: 22 additions & 16 deletions src/jetstream/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const (
jetstreamSessionName = "console-session"
jetStreamSessionContextKey = "jetstream-session"
jetStreamSessionContextUpdatedKey = "jetstream-session-updated"

// Header to communicate whether SSO Login is enabled and if so, any configured options
stratosSSOHeader = "x-stratos-sso-login"
)

// SessionValueNotFound - Error returned when a requested key was not found in the session
Expand Down Expand Up @@ -274,32 +277,35 @@ func (p *portalProxy) verifySession(c echo.Context) error {
return info, err
}

var jsonErr error

info, sessionVerifyErr := collectErrors(p, c)
if sessionVerifyErr != nil {
p.clearSessionCookie(c, true)

jsonErr = c.JSON(
// Add header so front-end knows SSO login is enabled
if p.Config.SSOLogin {
// A non-empty SSO Header means SSO is enabled
// Use the string "enabled" or send the options string if we have one
options := "enabled"
if len(p.Config.SSOOptions) > 0 {
options = p.Config.SSOOptions
}
c.Response().Header().Set(stratosSSOHeader, options)
}

return c.JSON(
http.StatusOK,
SessionInfoEnvelope{
Status: "error",
Error: sessionVerifyErr.Error(),
},
)
} else {
jsonErr = c.JSON(
http.StatusOK,
SessionInfoEnvelope{
Status: "ok",
Data: info,
},
)
}

if jsonErr != nil {
return jsonErr
}

return nil
return c.JSON(
http.StatusOK,
SessionInfoEnvelope{
Status: "ok",
Data: info,
},
)
}

0 comments on commit 2090d3c

Please sign in to comment.