Skip to content

Commit

Permalink
fix(ui+electron): OAuth2 > disableSSLVerification flag is not respect…
Browse files Browse the repository at this point in the history
…ed by oauth 2 requests (fixes #283)
  • Loading branch information
flawiddsouza committed Oct 15, 2024
1 parent d8bd377 commit 8d16787
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 28 deletions.
15 changes: 8 additions & 7 deletions packages/electron/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"electron-context-menu": "^3.6.1",
"electron-log": "^5.1.2",
"electron-squirrel-startup": "^1.0.0",
"open": "^10.1.0",
"undici": "^6.19.2",
"update-electron-app": "^2.0.1",
"jsonfile": "^4.0.0",
"mkdirp": "^0.5.1"
"mkdirp": "^0.5.1",
"open": "^10.1.0",
"undici": "^6.20.1",
"update-electron-app": "^2.0.1"
},
"config": {
"forge": "./forge.config.js"
Expand Down
File renamed without changes.
16 changes: 14 additions & 2 deletions packages/ui/src/components/FolderPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<div class="request-panel-tabs-context">
<div style="font-weight: 500; margin-bottom: var(--label-margin-bottom)">Headers</div>
<div>
<RequestPanelHeaders :collection-item="collectionItem" :collection-item-environment-resolved="envVariables"></RequestPanelHeaders>
<RequestPanelHeaders
:collection-item="collectionItem"
:collection-item-environment-resolved="envVariables"
/>
</div>
<InfoTip />
</div>
Expand All @@ -15,7 +18,11 @@
<div class="request-panel-tabs-context">
<div style="font-weight: 500; margin-bottom: var(--label-margin-bottom)">Auth</div>
<div>
<RequestPanelAuth :collection-item="collectionItem" :collection-item-environment-resolved="envVariables"></RequestPanelAuth>
<RequestPanelAuth
:collection-item="collectionItem"
:collection-item-environment-resolved="envVariables"
:flags="flags"
/>
</div>
<InfoTip />
</div>
Expand Down Expand Up @@ -56,6 +63,11 @@ export default {
envVariables: {},
}
},
computed: {
flags() {
return this.$store.state.flags
},
},
watch: {
collectionItem: {
immediate: true,
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/components/RequestPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
<RequestPanelAuth
:collection-item="activeTab"
:collection-item-environment-resolved="collectionItemEnvironmentResolved"
:flags="flags"
@tagClick="onTagClick"
/>
</template>
Expand Down Expand Up @@ -651,6 +652,9 @@ export default {
collectionItemEnvironmentResolved() {
return this.$store.state.tabEnvironmentResolved[this.activeTab._id] ?? {}
},
flags() {
return this.$store.state.flags
},
scriptPlugin() {
if(this.activeTab === null) {
return undefined
Expand Down
16 changes: 10 additions & 6 deletions packages/ui/src/components/RequestPanelAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
<script setup lang="ts">
import { computed, PropType, ref } from 'vue'
import CodeMirrorSingleLine from './CodeMirrorSingleLine.vue'
import { CollectionItem } from '@/global'
import { CollectionItem, Flags } from '@/global'
import ContextMenu from '@/components/ContextMenu.vue'
import constants from '@/constants'
import { fetchWrapper, substituteEnvironmentVariables } from '@/helpers'
Expand All @@ -293,7 +293,11 @@ const props = defineProps({
collectionItemEnvironmentResolved: {
type: Object as PropType<any>,
required: true
}
},
flags: {
type: Object as PropType<Flags>,
required: true
},
})
const emit = defineEmits(['tagClick'])
Expand Down Expand Up @@ -443,8 +447,8 @@ async function requestOAuthToken() {
}
const response = await fetchWrapper(accessTokenUrl, 'POST', headers, bodyData.toString(), abortController.signal, {
electronSwitchToChromiumFetch: false,
disableSSLVerification: false,
electronSwitchToChromiumFetch: props.flags.electronSwitchToChromiumFetch,
disableSSLVerification: props.flags.disableSSLVerification,
})
if(response.status !== 200) {
Expand Down Expand Up @@ -493,8 +497,8 @@ async function refreshOAuthToken() {
}
const response = await fetchWrapper(accessTokenUrl, 'POST', headers, bodyData.toString(), abortController.signal, {
electronSwitchToChromiumFetch: false,
disableSSLVerification: false,
electronSwitchToChromiumFetch: props.flags.electronSwitchToChromiumFetch,
disableSSLVerification: props.flags.disableSSLVerification,
})
if(response.status !== 200) {
Expand Down
20 changes: 11 additions & 9 deletions packages/ui/src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ export interface RequestFinalResponse {
name?: string
}

export interface Flags {
hideBrowserRelatedResponsePanelErrors: boolean
browserExtensionEnabled: boolean
isBrowser: boolean
isWebStandalone: boolean
isElectron: boolean
disableSSLVerification: boolean
electronSwitchToChromiumFetch: boolean
}

export interface State {
consoleLogs: string[]
collection: CollectionItem[]
Expand Down Expand Up @@ -139,15 +149,7 @@ export interface State {
theme: string
githubStarCount: string
sidebarItemTemporaryName: { [key: string]: string }
flags: {
hideBrowserRelatedResponsePanelErrors: boolean
browserExtensionEnabled: boolean
isBrowser: boolean
isWebStandalone: boolean
isElectron: boolean
disableSSLVerification: boolean
electronSwitchToChromiumFetch: boolean
}
flags: Flags
openContextMenuElement: HTMLElement | null
sockets: { [key: string]: WebSocket | null }
tabEnvironmentResolved: any
Expand Down

0 comments on commit 8d16787

Please sign in to comment.