diff --git a/src/frontend/packages/store/src/effects/auth.effects.ts b/src/frontend/packages/store/src/effects/auth.effects.ts index 15966e03a5..38c8883ba8 100644 --- a/src/frontend/packages/store/src/effects/auth.effects.ts +++ b/src/frontend/packages/store/src/effects/auth.effects.ts @@ -1,4 +1,4 @@ -import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; +import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; @@ -28,9 +28,9 @@ import { import { HydrateDashboardStateAction } from '../actions/dashboard-actions'; import { GET_ENDPOINTS_SUCCESS, GetAllEndpointsSuccess } from '../actions/endpoint.actions'; import { GetSystemInfo } from '../actions/system.actions'; +import { DispatchOnlyAppState } from '../app-state'; import { getDashboardStateSessionId } from '../helpers/store-helpers'; import { SessionData } from '../types/auth.types'; -import { DispatchOnlyAppState } from '../app-state'; const SETUP_HEADER = 'stratos-setup-required'; const UPGRADE_HEADER = 'retry-after'; @@ -50,8 +50,6 @@ export class AuthEffect { @Effect() loginRequest$ = this.actions$.pipe( ofType(LOGIN), switchMap(({ username, password }) => { - const encoder = new BrowserStandardEncoder(); - const headers = new HttpHeaders(); const params = new HttpParams({ encoder: new BrowserStandardEncoder(), fromObject: { @@ -59,9 +57,10 @@ export class AuthEffect { password } }); + const headers = { + 'x-cap-request-date': (Math.floor(Date.now() / 1000)).toString() + }; - headers.set('Content-Type', 'application/x-www-form-urlencoded'); - headers.set('x-cap-request-date', (Math.floor(Date.now() / 1000)).toString()); return this.http.post('/pp/v1/auth/login/uaa', params, { headers, }).pipe( @@ -72,8 +71,10 @@ export class AuthEffect { @Effect() verifyAuth$ = this.actions$.pipe( ofType(VERIFY_SESSION), switchMap(action => { - const headers = new HttpHeaders(); - headers.set('x-cap-request-date', (Math.floor(Date.now() / 1000)).toString()); + const headers = { + 'x-cap-request-date': (Math.floor(Date.now() / 1000)).toString() + }; + return this.http.get('/pp/v1/auth/session/verify', { headers, observe: 'response', diff --git a/src/frontend/packages/store/src/effects/endpoint.effects.ts b/src/frontend/packages/store/src/effects/endpoint.effects.ts index d5deac379f..ae60aeff15 100644 --- a/src/frontend/packages/store/src/effects/endpoint.effects.ts +++ b/src/frontend/packages/store/src/effects/endpoint.effects.ts @@ -1,4 +1,4 @@ -import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams } from '@angular/common/http'; +import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; @@ -274,11 +274,8 @@ export class EndpointsEffect { errorMessageHandler?: (e: any) => string, ) { const endpointEntityKey = entityCatalogue.getEntityKey(apiAction); - const headers = new HttpHeaders(); - headers.set('Content-Type', 'application/x-www-form-urlencoded'); this.store.dispatch(new StartRequestAction(apiAction, apiActionType)); return this.http.post(url, body || {}, { - headers, params }).pipe( mergeMap((endpoint: EndpointModel) => { diff --git a/src/jetstream/authuaa.go b/src/jetstream/authuaa.go index f5d7ee3113..63b152eab4 100644 --- a/src/jetstream/authuaa.go +++ b/src/jetstream/authuaa.go @@ -151,11 +151,6 @@ func (a *uaaAuth) VerifySession(c echo.Context, sessionUser string, sessionExpir if err = a.p.setSessionValues(c, sessionValues); err != nil { return err } - } else { - // Still need to extend the expires_on of the Session - if err = a.p.setSessionValues(c, nil); err != nil { - return err - } } return nil diff --git a/src/jetstream/session.go b/src/jetstream/session.go index 0564099004..79c331614a 100644 --- a/src/jetstream/session.go +++ b/src/jetstream/session.go @@ -16,7 +16,6 @@ import ( const ( - // XSRFTokenHeader - XSRF Token Header name XSRFTokenHeader = "X-Xsrf-Token" // XSRFTokenSessionName - XSRF Token Session name @@ -32,13 +31,8 @@ const ( jetstreamSessionName = "console-session" jetStreamSessionContextKey = "jetstream-session" jetStreamSessionContextUpdatedKey = "jetstream-session-updated" - ) - - - - // SessionValueNotFound - Error returned when a requested key was not found in the session type SessionValueNotFound struct { msg string @@ -254,6 +248,11 @@ func (p *portalProxy) verifySession(c echo.Context) error { } else { + // Still need to extend the expires_on of the Session (set session will save session, in save we update `expires_on`) + if err = p.setSessionValues(c, nil); err != nil { + return err + } + err = p.handleSessionExpiryHeader(c) if err != nil { return err @@ -272,6 +271,6 @@ func (p *portalProxy) verifySession(c echo.Context) error { return err } } - + return err }