Skip to content

Commit

Permalink
Addressing spelling mistakes in server code. (#1753)
Browse files Browse the repository at this point in the history
* Addressing spelling mistakes in server code.

Signed-off-by: Shawn Houston <[email protected]>

* Corrected cammel case of renamed variable.

Signed-off-by: Shawn Houston <[email protected]>

---------

Signed-off-by: Shawn Houston <[email protected]>
(cherry picked from commit f854cb3)
  • Loading branch information
shoustech authored and github-actions[bot] committed Jan 23, 2024
1 parent 2c2b9ad commit 2c583cd
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
16 changes: 8 additions & 8 deletions server/auth/types/authentication_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface OpenSearchDashboardsAuthState {

export abstract class AuthenticationType implements IAuthenticationType {
protected static readonly ROUTES_TO_IGNORE: string[] = [
'/api/core/capabilities', // FIXME: need to figureout how to bypass this API call
'/api/core/capabilities', // FIXME: need to figure out how to bypass this API call
'/app/login',
];

Expand Down Expand Up @@ -106,7 +106,7 @@ export abstract class AuthenticationType implements IAuthenticationType {
const authState: OpenSearchDashboardsAuthState = {};

// if browser request, auth logic is:
// 1. check if request includes auth header or paramter(e.g. jwt in url params) is present, if so, authenticate with auth header.
// 1. check if request includes auth header or parameter(e.g. jwt in url params) is present, if so, authenticate with auth header.
// 2. if auth header not present, check if auth cookie is present, if no cookie, send to authentication workflow
// 3. verify whether auth cookie is valid, if not valid, send to authentication workflow
// 4. if cookie is valid, pass to route handlers
Expand All @@ -117,9 +117,9 @@ export abstract class AuthenticationType implements IAuthenticationType {
// see https://www.elastic.co/guide/en/opensearch-dashboards/master/using-api.html
if (this.requestIncludesAuthInfo(request)) {
try {
const additonalAuthHeader = await this.getAdditionalAuthHeader(request);
Object.assign(authHeaders, additonalAuthHeader);
authInfo = await this.securityClient.authinfo(request, additonalAuthHeader);
const additionalAuthHeader = await this.getAdditionalAuthHeader(request);
Object.assign(authHeaders, additionalAuthHeader);
authInfo = await this.securityClient.authinfo(request, additionalAuthHeader);
cookie = this.getCookie(request, authInfo);

// set tenant from cookie if exist
Expand Down Expand Up @@ -167,8 +167,8 @@ export abstract class AuthenticationType implements IAuthenticationType {
// build auth header
const authHeadersFromCookie = this.buildAuthHeaderFromCookie(cookie!, request);
Object.assign(authHeaders, authHeadersFromCookie);
const additonalAuthHeader = await this.getAdditionalAuthHeader(request);
Object.assign(authHeaders, additonalAuthHeader);
const additionalAuthHeader = await this.getAdditionalAuthHeader(request);
Object.assign(authHeaders, additionalAuthHeader);
}

// resolve tenant if necessary
Expand Down Expand Up @@ -257,7 +257,7 @@ export abstract class AuthenticationType implements IAuthenticationType {
request,
username: authInfo.user_name,
roles: authInfo.roles,
availabeTenants: authInfo.tenants,
availableTenants: authInfo.tenants,
config: this.config,
cookie,
multitenancyEnabled: dashboardsInfo.multitenancy_enabled,
Expand Down
4 changes: 2 additions & 2 deletions server/auth/types/basic/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class BasicAuthRoutes {
request,
username: user.username,
roles: user.roles,
availabeTenants: user.tenants,
availableTenants: user.tenants,
config: this.config,
cookie: sessionStorage,
multitenancyEnabled: user.multitenancy_enabled,
Expand Down Expand Up @@ -213,7 +213,7 @@ export class BasicAuthRoutes {
request,
username: user.username,
roles: user.roles,
availabeTenants: user.tenants,
availableTenants: user.tenants,
config: this.config,
cookie: sessionStorage,
multitenancyEnabled: user.multitenancy_enabled,
Expand Down
4 changes: 2 additions & 2 deletions server/auth/types/openid/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ export function composeLogoutUrl(
idpEndsessionEndpoint: string | undefined,
additionalQueryParams: any
) {
const logoutEndpont = customLogoutUrl || idpEndsessionEndpoint;
const logoutUrl = new URL(logoutEndpont!);
const logoutEndpoint = customLogoutUrl || idpEndsessionEndpoint;
const logoutUrl = new URL(logoutEndpoint!);
Object.keys(additionalQueryParams).forEach((key) => {
logoutUrl.searchParams.append(key, additionalQueryParams[key] as string);
});
Expand Down
2 changes: 1 addition & 1 deletion server/backend/opensearch_security_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class SecurityClient {
username: esResponse.user_name,
roles: esResponse.roles,
backendRoles: esResponse.backend_roles,
tenants: esResponse.teanats,
tenants: esResponse.tenants,
selectedTenant: esResponse.user_requested_tenant,
credentials,
};
Expand Down
8 changes: 4 additions & 4 deletions server/multitenancy/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { SecurityClient } from '../backend/opensearch_security_client';

export function setupMultitenantRoutes(
router: IRouter,
sessionStroageFactory: SessionStorageFactory<SecuritySessionCookie>,
sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>,
securityClient: SecurityClient
) {
const PREFIX: string = '/api/v1';
Expand All @@ -44,7 +44,7 @@ export function setupMultitenantRoutes(
async (context, request, response) => {
const tenant = request.body.tenant;

const cookie: SecuritySessionCookie | null = await sessionStroageFactory
const cookie: SecuritySessionCookie | null = await sessionStorageFactory
.asScoped(request)
.get();
if (!cookie) {
Expand All @@ -53,7 +53,7 @@ export function setupMultitenantRoutes(
});
}
cookie.tenant = tenant;
sessionStroageFactory.asScoped(request).set(cookie);
sessionStorageFactory.asScoped(request).set(cookie);
return response.ok({
body: entities.encode(tenant),
});
Expand All @@ -69,7 +69,7 @@ export function setupMultitenantRoutes(
validate: false,
},
async (context, request, response) => {
const cookie = await sessionStroageFactory.asScoped(request).get();
const cookie = await sessionStorageFactory.asScoped(request).get();
if (!cookie) {
return response.badRequest({
body: 'Invalid cookie.',
Expand Down
6 changes: 3 additions & 3 deletions server/multitenancy/tenant_index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export async function migrateTenantIndices(
serializer: SavedObjectsSerializer,
logger: Logger
) {
let tenentInfo: any;
let tenantInfo: any;
try {
tenentInfo = await securityClient.getTenantInfoWithInternalUser();
tenantInfo = await securityClient.getTenantInfoWithInternalUser();
} catch (error) {
logger.error(error);
throw error;
Expand All @@ -94,7 +94,7 @@ export async function migrateTenantIndices(
log: logger,
});

for (const indexName of Object.keys(tenentInfo)) {
for (const indexName of Object.keys(tenantInfo)) {
const indexMap = createIndexMap({
opensearchDashboardsIndexName: indexName,
indexMap: mergeTypes(typeRegistry.getAllTypes()),
Expand Down
10 changes: 5 additions & 5 deletions server/multitenancy/tenant_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const GLOBAL_TENANTS: string[] = ['global', GLOBAL_TENANT_SYMBOL, 'Global
* @param request OpenSearchDashboards request.
* @param username
* @param roles
* @param availabeTenants
* @param availableTenants
* @param config security plugin config.
* @param cookie cookie extracted from the request. The cookie should have been parsed by AuthenticationHandler.
* pass it as parameter instead of extracting again.
Expand All @@ -45,7 +45,7 @@ export function resolveTenant({
request,
username,
roles,
availabeTenants,
availableTenants,
config,
cookie,
multitenancyEnabled,
Expand All @@ -55,7 +55,7 @@ export function resolveTenant({
request: any;
username: string;
roles: string[] | undefined;
availabeTenants: any;
availableTenants: any;
config: SecurityPluginConfigType;
cookie: SecuritySessionCookie;
multitenancyEnabled: boolean;
Expand Down Expand Up @@ -96,7 +96,7 @@ export function resolveTenant({
username,
selectedTenant,
preferredTenants,
availabeTenants,
availableTenants,
globalTenantEnabled,
multitenancyEnabled,
privateTenantEnabled
Expand Down Expand Up @@ -190,7 +190,7 @@ export function resolve(
}

/**
* Return true if tenant parameter is a valid tenent.
* Return true if tenant parameter is a valid tenant.
*
* Note: empty string '' is valid, which means global tenant.
*
Expand Down
6 changes: 3 additions & 3 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
import { SecurityPluginSetup, SecurityPluginStart } from './types';
import { defineRoutes } from './routes';
import { SecurityPluginConfigType } from '.';
import opensearchSecurityConfiguratoinPlugin from './backend/opensearch_security_configuration_plugin';
import opensearchSecurityConfigurationPlugin from './backend/opensearch_security_configuration_plugin';
import opensearchSecurityPlugin from './backend/opensearch_security_plugin';
import { SecuritySessionCookie, getSecurityCookieOptions } from './session/security_cookie';
import { SecurityClient } from './backend/opensearch_security_client';
Expand Down Expand Up @@ -94,7 +94,7 @@ export class SecurityPlugin implements Plugin<SecurityPluginSetup, SecurityPlugi
const esClient: ILegacyClusterClient = core.opensearch.legacy.createClient(
'opendistro_security',
{
plugins: [opensearchSecurityConfiguratoinPlugin, opensearchSecurityPlugin],
plugins: [opensearchSecurityConfigurationPlugin, opensearchSecurityPlugin],
}
);

Expand Down Expand Up @@ -136,7 +136,7 @@ export class SecurityPlugin implements Plugin<SecurityPluginSetup, SecurityPlugi
defineRoutes(router);
defineAuthTypeRoutes(router, config);

// set up multi-tenent routes
// set up multi-tenant routes
if (config.multitenancy?.enabled) {
setupMultitenantRoutes(router, securitySessionStorageFactory, this.securityClient);
}
Expand Down
2 changes: 1 addition & 1 deletion server/session/security_cookie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function getSecurityCookieOptions(
}

// TODO: with setting redirect attributes to support OIDC and SAML,
// we need to do additonal cookie validatin in AuthenticationHandlers.
// we need to do additional cookie validation in AuthenticationHandlers.
// if SAML fields present
if (sessionStorage.saml && sessionStorage.saml.requestId && sessionStorage.saml.nextUrl) {
return { isValid: true, path: '/' };
Expand Down

0 comments on commit 2c583cd

Please sign in to comment.