Skip to content

Commit

Permalink
chore: introduce supportsDigestAuth field at the interceptor servic…
Browse files Browse the repository at this point in the history
…e level
  • Loading branch information
jamesgeorge007 committed Oct 30, 2024
1 parent 8643819 commit ac3c2f7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
5 changes: 0 additions & 5 deletions packages/hoppscotch-common/src/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ export type PlatformDef = {
* Whether to show the A/B testing workspace switcher click login flow or not
*/
workspaceSwitcherLogin?: Ref<boolean>

/**
* Whether to show the warning about supported interceptors while using the Digest Authorization type
*/
showInterceptorWarningForDigestAuth?: boolean
}
limits?: LimitsPlatformDef
infra?: InfraPlatformDef
Expand Down
1 change: 0 additions & 1 deletion packages/hoppscotch-common/src/platform/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ export type PlatformInterceptorDef =
export type InterceptorsPlatformDef = {
default: string
interceptors: PlatformInterceptorDef[]
showInterceptorWarningForDigestAuth?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ export class AgentInterceptorService extends Service implements Interceptor {

public proxyInfo = ref<RequestDef["proxy"]>(undefined)

public supportsDigestAuth = true

override onServiceInit() {
// Register the Root UI Extension
this.uiExtensionService.addRootUIExtension(AgentRootUIExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { Service } from "dioc"
import { computed, markRaw, Ref } from "vue"

import { getI18n } from "~/modules/i18n"
import { platform } from "~/platform"
import { AgentInterceptorService } from "~/platform/std/interceptors/agent"
import { InterceptorService } from "~/services/interceptor.service"
import { RESTTabService } from "~/services/tab/rest"
import IconAlertTriangle from "~icons/lucide/alert-triangle"
Expand All @@ -31,7 +29,6 @@ export class AuthorizationInspectorService

private readonly inspection = this.bind(InspectionService)
private readonly interceptorService = this.bind(InterceptorService)
private readonly agentService = this.bind(AgentInterceptorService)
private readonly restTabService = this.bind(RESTTabService)

override onServiceInit() {
Expand Down Expand Up @@ -74,15 +71,12 @@ export class AuthorizationInspectorService

const results: InspectorResult[] = []

// `Agent` interceptor is recommended while using Digest Auth
const isUnsupportedInterceptor =
platform.platformFeatureFlags.showInterceptorWarningForDigestAuth &&
this.interceptorService.currentInterceptorID.value !==
this.agentService.interceptorID

const resolvedAuthType = this.resolveAuthType(auth)

if (resolvedAuthType === "digest" && isUnsupportedInterceptor) {
if (
resolvedAuthType === "digest" &&
!this.interceptorService.currentInterceptor.value?.supportsDigestAuth
) {
results.push({
id: "url",
icon: markRaw(IconAlertTriangle),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export type Interceptor<Err extends InterceptorError = InterceptorError> = {
* @param request The request to run the interceptor on.
*/
runRequest: (request: AxiosRequestConfig) => RequestRunResult<Err>

/**
* Defines whether the interceptor has support for Digest Auth.
* If this field is undefined, it is assumed as not supporting the Digest Auth type.
*/
supportsDigestAuth?: boolean
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ export class NativeInterceptorService extends Service implements Interceptor {
public validateCerts = ref(true)
public proxyInfo = ref<RequestDef["proxy"]>(undefined)

public supportsDigestAuth = true

override onServiceInit() {
// Load SSL Validation
const persistedValidateSSL: unknown = JSON.parse(
Expand Down
1 change: 0 additions & 1 deletion packages/hoppscotch-selfhost-web/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ createHoppApp("#app", {
platformFeatureFlags: {
exportAsGIST: false,
hasTelemetry: false,
showInterceptorWarningForDigestAuth: true,
},
limits: {
collectionImportSizeLimit: 50,
Expand Down

0 comments on commit ac3c2f7

Please sign in to comment.