Skip to content

Commit

Permalink
Clear split cookies on logout
Browse files Browse the repository at this point in the history
Signed-off-by: Jochen Kressin <[email protected]>
  • Loading branch information
jochen-kressin committed Dec 31, 2023
1 parent a81f796 commit 7c532e6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/auth/types/jwt/jwt_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class JwtAuthentication extends AuthenticationType {

public async init() {
this.createExtraStorage();
const routes = new JwtAuthRoutes(this.router, this.sessionStorageFactory);
const routes = new JwtAuthRoutes(this.router, this.sessionStorageFactory, this.config);
routes.setupRoutes();
}

Expand Down
33 changes: 31 additions & 2 deletions server/auth/types/jwt/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,41 @@
* permissions and limitations under the License.
*/

import { IRouter, SessionStorageFactory } from 'opensearch-dashboards/server';
import {

Check failure on line 16 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `⏎··IRouter,⏎··Logger,⏎··SessionStorageFactory⏎` with `·IRouter,·Logger,·SessionStorageFactory·`

Check failure on line 16 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `⏎··IRouter,⏎··Logger,⏎··SessionStorageFactory⏎` with `·IRouter,·Logger,·SessionStorageFactory·`

Check failure on line 16 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `␍⏎··IRouter,␍⏎··Logger,␍⏎··SessionStorageFactory␍⏎` with `·IRouter,·Logger,·SessionStorageFactory·`
IRouter,
Logger,
SessionStorageFactory
} from 'opensearch-dashboards/server';
import { SecuritySessionCookie } from '../../../session/security_cookie';
import { API_AUTH_LOGOUT, API_PREFIX } from '../../../../common';
import {

Check failure on line 23 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `⏎··clearSplitCookies,⏎··ExtraAuthStorageOptions⏎}·from·"../../../session/cookie_splitter"` with `·clearSplitCookies,·ExtraAuthStorageOptions·}·from·'../../../session/cookie_splitter'`

Check failure on line 23 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `⏎··clearSplitCookies,⏎··ExtraAuthStorageOptions⏎}·from·"../../../session/cookie_splitter"` with `·clearSplitCookies,·ExtraAuthStorageOptions·}·from·'../../../session/cookie_splitter'`

Check failure on line 23 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `␍⏎··clearSplitCookies,␍⏎··ExtraAuthStorageOptions␍⏎}·from·"../../../session/cookie_splitter"` with `·clearSplitCookies,·ExtraAuthStorageOptions·}·from·'../../../session/cookie_splitter'`
clearSplitCookies,
ExtraAuthStorageOptions
} from "../../../session/cookie_splitter";
import {JWT_DEFAULT_EXTRA_STORAGE_OPTIONS} from "./jwt_auth";

Check failure on line 27 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `JWT_DEFAULT_EXTRA_STORAGE_OPTIONS}·from·"./jwt_auth"` with `·JWT_DEFAULT_EXTRA_STORAGE_OPTIONS·}·from·'./jwt_auth'`

Check failure on line 27 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `JWT_DEFAULT_EXTRA_STORAGE_OPTIONS}·from·"./jwt_auth"` with `·JWT_DEFAULT_EXTRA_STORAGE_OPTIONS·}·from·'./jwt_auth'`

Check failure on line 27 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `JWT_DEFAULT_EXTRA_STORAGE_OPTIONS}·from·"./jwt_auth"` with `·JWT_DEFAULT_EXTRA_STORAGE_OPTIONS·}·from·'./jwt_auth'`
import {SecurityPluginConfigType} from "../../../index";

Check failure on line 28 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `SecurityPluginConfigType}·from·"../../../index"` with `·SecurityPluginConfigType·}·from·'../../../index'`

Check failure on line 28 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `SecurityPluginConfigType}·from·"../../../index"` with `·SecurityPluginConfigType·}·from·'../../../index'`

Check failure on line 28 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `SecurityPluginConfigType}·from·"../../../index"` with `·SecurityPluginConfigType·}·from·'../../../index'`

export class JwtAuthRoutes {
constructor(
private readonly router: IRouter,
private readonly sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>
private readonly sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>,
private readonly config: SecurityPluginConfigType,

Check failure on line 34 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Delete `,`

Check failure on line 34 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Delete `,`

Check failure on line 34 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Delete `,`
) {}

private getExtraAuthStorageOptions(logger?: Logger): ExtraAuthStorageOptions {
const extraAuthStorageOptions: ExtraAuthStorageOptions = {
cookiePrefix:
this.config.jwt?.extra_storage.cookie_prefix ||
JWT_DEFAULT_EXTRA_STORAGE_OPTIONS.cookiePrefix,
additionalCookies:
this.config.jwt?.extra_storage.additional_cookies ||
JWT_DEFAULT_EXTRA_STORAGE_OPTIONS.additionalCookies,
logger: logger,

Check failure on line 45 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Expected property shorthand

Check failure on line 45 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Expected property shorthand

Check failure on line 45 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Expected property shorthand
};

return extraAuthStorageOptions;
}

public setupRoutes() {
this.router.post(
{
Expand All @@ -33,6 +58,10 @@ export class JwtAuthRoutes {
},
},
async (context, request, response) => {
await clearSplitCookies(

Check failure on line 61 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Replace `⏎··········request,⏎··········this.getExtraAuthStorageOptions()⏎········` with `request,·this.getExtraAuthStorageOptions()`

Check failure on line 61 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (macos-latest)

Replace `⏎··········request,⏎··········this.getExtraAuthStorageOptions()⏎········` with `request,·this.getExtraAuthStorageOptions()`

Check failure on line 61 in server/auth/types/jwt/routes.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Replace `␍⏎··········request,␍⏎··········this.getExtraAuthStorageOptions()␍⏎········` with `request,·this.getExtraAuthStorageOptions()`
request,
this.getExtraAuthStorageOptions()
);
this.sessionStorageFactory.asScoped(request).clear();
return response.ok();
}
Expand Down

0 comments on commit 7c532e6

Please sign in to comment.