mirror of
https://github.com/hoppscotch/hoppscotch
synced 2024-11-21 22:50:51 +00:00
chore: introduce supportsDigestAuth
field at the interceptor service level (#4498)
This commit is contained in:
parent
8643819926
commit
223dd25788
@ -54,11 +54,6 @@ export type PlatformDef = {
|
|||||||
* Whether to show the A/B testing workspace switcher click login flow or not
|
* Whether to show the A/B testing workspace switcher click login flow or not
|
||||||
*/
|
*/
|
||||||
workspaceSwitcherLogin?: Ref<boolean>
|
workspaceSwitcherLogin?: Ref<boolean>
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether to show the warning about supported interceptors while using the Digest Authorization type
|
|
||||||
*/
|
|
||||||
showInterceptorWarningForDigestAuth?: boolean
|
|
||||||
}
|
}
|
||||||
limits?: LimitsPlatformDef
|
limits?: LimitsPlatformDef
|
||||||
infra?: InfraPlatformDef
|
infra?: InfraPlatformDef
|
||||||
|
@ -14,5 +14,4 @@ export type PlatformInterceptorDef =
|
|||||||
export type InterceptorsPlatformDef = {
|
export type InterceptorsPlatformDef = {
|
||||||
default: string
|
default: string
|
||||||
interceptors: PlatformInterceptorDef[]
|
interceptors: PlatformInterceptorDef[]
|
||||||
showInterceptorWarningForDigestAuth?: boolean
|
|
||||||
}
|
}
|
||||||
|
@ -302,6 +302,8 @@ export class AgentInterceptorService extends Service implements Interceptor {
|
|||||||
|
|
||||||
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
|
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
|
||||||
|
|
||||||
|
public supportsDigestAuth = true
|
||||||
|
|
||||||
override onServiceInit() {
|
override onServiceInit() {
|
||||||
// Register the Root UI Extension
|
// Register the Root UI Extension
|
||||||
this.uiExtensionService.addRootUIExtension(AgentRootUIExtension)
|
this.uiExtensionService.addRootUIExtension(AgentRootUIExtension)
|
||||||
|
@ -6,8 +6,6 @@ import { Service } from "dioc"
|
|||||||
import { computed, markRaw, Ref } from "vue"
|
import { computed, markRaw, Ref } from "vue"
|
||||||
|
|
||||||
import { getI18n } from "~/modules/i18n"
|
import { getI18n } from "~/modules/i18n"
|
||||||
import { platform } from "~/platform"
|
|
||||||
import { AgentInterceptorService } from "~/platform/std/interceptors/agent"
|
|
||||||
import { InterceptorService } from "~/services/interceptor.service"
|
import { InterceptorService } from "~/services/interceptor.service"
|
||||||
import { RESTTabService } from "~/services/tab/rest"
|
import { RESTTabService } from "~/services/tab/rest"
|
||||||
import IconAlertTriangle from "~icons/lucide/alert-triangle"
|
import IconAlertTriangle from "~icons/lucide/alert-triangle"
|
||||||
@ -31,7 +29,6 @@ export class AuthorizationInspectorService
|
|||||||
|
|
||||||
private readonly inspection = this.bind(InspectionService)
|
private readonly inspection = this.bind(InspectionService)
|
||||||
private readonly interceptorService = this.bind(InterceptorService)
|
private readonly interceptorService = this.bind(InterceptorService)
|
||||||
private readonly agentService = this.bind(AgentInterceptorService)
|
|
||||||
private readonly restTabService = this.bind(RESTTabService)
|
private readonly restTabService = this.bind(RESTTabService)
|
||||||
|
|
||||||
override onServiceInit() {
|
override onServiceInit() {
|
||||||
@ -74,15 +71,12 @@ export class AuthorizationInspectorService
|
|||||||
|
|
||||||
const results: InspectorResult[] = []
|
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)
|
const resolvedAuthType = this.resolveAuthType(auth)
|
||||||
|
|
||||||
if (resolvedAuthType === "digest" && isUnsupportedInterceptor) {
|
if (
|
||||||
|
resolvedAuthType === "digest" &&
|
||||||
|
!this.interceptorService.currentInterceptor.value?.supportsDigestAuth
|
||||||
|
) {
|
||||||
results.push({
|
results.push({
|
||||||
id: "url",
|
id: "url",
|
||||||
icon: markRaw(IconAlertTriangle),
|
icon: markRaw(IconAlertTriangle),
|
||||||
|
@ -141,6 +141,12 @@ export type Interceptor<Err extends InterceptorError = InterceptorError> = {
|
|||||||
* @param request The request to run the interceptor on.
|
* @param request The request to run the interceptor on.
|
||||||
*/
|
*/
|
||||||
runRequest: (request: AxiosRequestConfig) => RequestRunResult<Err>
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -277,6 +277,8 @@ export class NativeInterceptorService extends Service implements Interceptor {
|
|||||||
public validateCerts = ref(true)
|
public validateCerts = ref(true)
|
||||||
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
|
public proxyInfo = ref<RequestDef["proxy"]>(undefined)
|
||||||
|
|
||||||
|
public supportsDigestAuth = true
|
||||||
|
|
||||||
override onServiceInit() {
|
override onServiceInit() {
|
||||||
// Load SSL Validation
|
// Load SSL Validation
|
||||||
const persistedValidateSSL: unknown = JSON.parse(
|
const persistedValidateSSL: unknown = JSON.parse(
|
||||||
|
@ -42,7 +42,6 @@ createHoppApp("#app", {
|
|||||||
platformFeatureFlags: {
|
platformFeatureFlags: {
|
||||||
exportAsGIST: false,
|
exportAsGIST: false,
|
||||||
hasTelemetry: false,
|
hasTelemetry: false,
|
||||||
showInterceptorWarningForDigestAuth: true,
|
|
||||||
},
|
},
|
||||||
limits: {
|
limits: {
|
||||||
collectionImportSizeLimit: 50,
|
collectionImportSizeLimit: 50,
|
||||||
|
Loading…
Reference in New Issue
Block a user