Skip to content

Commit

Permalink
Revert "feat: add authentication setting (#487)" (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Jul 15, 2024
1 parent bd3ffb6 commit bb19865
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 52 deletions.
6 changes: 1 addition & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# Snyk Security Changelog

## [2.13.2]
- allow to select oauth2 authentication

## [2.13.1]
### [2.13.1]
- Refactor the Suggestion Panel for OSS so it's more secure and will be supported in other IDEs
- allow to select OAuth2 as authentication

## [2.13.0]
- Fix `.suggestion` class to ensure it is scrollable and not overlapped by the `.suggestion-actions` fixed element. This change prevents the suggestion content from being hidden.
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@
"scope": "window",
"pattern": "^(|(https?://)api.*.(snyk|snykgov).io)$"
},
"snyk.advanced.useTokenAuthentication": {
"type": "boolean",
"markdownDescription": "Use token authentication. It is recommended to keep this turned off, as the default OAuth2 authentication is more secure.",
"scope": "window",
"default": true
},
"snyk.advanced.organization": {
"type": "string",
"markdownDescription": "Specifies an organization slug name to run tests for that organization. \n\nNote: The slug name can be extracted from the URL of your organization in the Snyk UI: `https://app.snyk.io/org/[orgslugname]`. If not specified, preferred organization as defined in your [web account settings](https://app.snyk.io/account) is used to run tests.",
Expand Down
23 changes: 1 addition & 22 deletions src/snyk/common/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
YES_BACKGROUND_OSS_NOTIFICATION_SETTING,
YES_CRASH_REPORT_SETTING,
YES_WELCOME_NOTIFICATION_SETTING,
ADVANCED_USE_TOKEN_AUTHENTICATION,
DELTA_FINDINGS,
} from '../constants/settings';
import SecretStorageAdapter from '../vscode/secretStorage';
Expand Down Expand Up @@ -63,10 +62,6 @@ export interface IConfiguration {

authHost: string;

useTokenAuthentication(): boolean;

setUseTokenAuthentication(useTokenAuth: boolean): void;

getFeatureFlag(flagName: string): boolean;

setFeatureFlag(flagName: string, value: boolean): void;
Expand Down Expand Up @@ -130,6 +125,7 @@ export interface IConfiguration {

export class Configuration implements IConfiguration {
// These attributes are used in tests
private readonly defaultSnykCodeBaseURL = 'https://deeproxy.snyk.io';
private readonly defaultAuthHost = 'https://app.snyk.io';
private readonly defaultApiEndpoint = 'https://api.snyk.io';

Expand All @@ -142,23 +138,6 @@ export class Configuration implements IConfiguration {
return !strictSSL;
}

useTokenAuthentication(): boolean {
const useTokenAuth = this.workspace.getConfiguration<boolean>(
CONFIGURATION_IDENTIFIER,
this.getConfigName(ADVANCED_USE_TOKEN_AUTHENTICATION),
);
return useTokenAuth ?? false;
}

async setUseTokenAuthentication(useTokenAuth: boolean): Promise<void> {
await this.workspace.updateConfiguration(
CONFIGURATION_IDENTIFIER,
this.getConfigName(ADVANCED_USE_TOKEN_AUTHENTICATION),
useTokenAuth,
true,
);
}

static async getVersion(): Promise<string> {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version } = await this.getPackageJsonConfig();
Expand Down
1 change: 0 additions & 1 deletion src/snyk/common/constants/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const ADVANCED_ORGANIZATION = `${CONFIGURATION_IDENTIFIER}.advanced.organ
export const ADVANCED_AUTOMATIC_DEPENDENCY_MANAGEMENT = `${CONFIGURATION_IDENTIFIER}.advanced.automaticDependencyManagement`;
export const ADVANCED_CLI_PATH = `${CONFIGURATION_IDENTIFIER}.advanced.cliPath`;
export const ADVANCED_CUSTOM_LS_PATH = `${CONFIGURATION_IDENTIFIER}.advanced.languageServerPath`;
export const ADVANCED_USE_TOKEN_AUTHENTICATION = `${CONFIGURATION_IDENTIFIER}.advanced.useTokenAuthentication`;

export const ISSUE_VIEW_OPTIONS_SETTING = `${CONFIGURATION_IDENTIFIER}.issueViewOptions`;
export const SEVERITY_FILTER_SETTING = `${CONFIGURATION_IDENTIFIER}.severity`;
Expand Down
7 changes: 0 additions & 7 deletions src/snyk/common/languageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export type ServerSettings = {
// Authentication and parameters
token?: string;
automaticAuthentication?: string;
authenticationMethod?: string;
additionalParams?: string;
manageBinariesAutomatically?: string;

Expand Down Expand Up @@ -58,11 +57,6 @@ export class LanguageServerSettings {
? true
: featuresConfiguration.codeQualityEnabled;

let authenticationMethod = 'oauth';
if (configuration.useTokenAuthentication()) {
authenticationMethod = 'token';
}

return {
activateSnykCodeSecurity: `${codeSecurityEnabled}`,
activateSnykCodeQuality: `${codeQualityEnabled}`,
Expand All @@ -86,7 +80,6 @@ export class LanguageServerSettings {
integrationVersion: await Configuration.getVersion(),
deviceId: user.anonymousId,
requiredProtocolVersion: `${PROTOCOL_VERSION}`,
authenticationMethod: authenticationMethod,
};
}
}
5 changes: 0 additions & 5 deletions src/test/unit/common/languageServer/languageServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ suite('Language Server', () => {

setup(() => {
configurationMock = {
useTokenAuthentication(): boolean {
return false;
},

getInsecure(): boolean {
return true;
},
Expand Down Expand Up @@ -227,7 +223,6 @@ suite('Language Server', () => {
insecure: 'true',
requiredProtocolVersion: '12',
scanningMode: 'auto',
authenticationMethod: 'oauth',
};

deepStrictEqual(await languageServer.getInitializationOptions(), expectedInitializationOptions);
Expand Down
3 changes: 0 additions & 3 deletions src/test/unit/common/languageServer/middleware.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ suite('Language Server: Middleware', () => {
setup(() => {
user = { anonymousId: 'anonymous-id' } as User;
configuration = {
useTokenAuthentication(): boolean {
return false;
},
shouldReportErrors: false,
snykApiEndpoint: 'https://dev.snyk.io/api',
getAdditionalCliParameters: () => '',
Expand Down
3 changes: 0 additions & 3 deletions src/test/unit/common/languageServer/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ suite('LanguageServerSettings', () => {
organization: 'my-org',
// eslint-disable-next-line @typescript-eslint/require-await
getToken: async () => 'snyk-token',
useTokenAuthentication(): boolean {
return false;
},
getFeaturesConfiguration: () => ({}), // iacEnabled, codeSecurityEnabled, codeQualityEnabled are undefined
getCliPath: () => '/path/to/cli',
getAdditionalCliParameters: () => '--all-projects -d',
Expand Down

0 comments on commit bb19865

Please sign in to comment.