chore: AWS Signature Authorization type flow updates (#4311)
Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
@@ -137,7 +137,7 @@ describe("hopp test [options] <file_path_or_id>", () => {
|
|||||||
|
|
||||||
expect(error).toBeNull();
|
expect(error).toBeNull();
|
||||||
},
|
},
|
||||||
{ timeout: 50000 }
|
{ timeout: 100000 }
|
||||||
);
|
);
|
||||||
|
|
||||||
test("Persists environment variables set in the pre-request script for consumption in the test script", async () => {
|
test("Persists environment variables set in the pre-request script for consumption in the test script", async () => {
|
||||||
@@ -366,7 +366,7 @@ describe("hopp test [options] <file_path_or_id>", () => {
|
|||||||
expect(error).toBeNull();
|
expect(error).toBeNull();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{ timeout: 20000 }
|
{ timeout: 50000 }
|
||||||
);
|
);
|
||||||
|
|
||||||
describe("Request variables", () => {
|
describe("Request variables", () => {
|
||||||
|
|||||||
@@ -101,7 +101,8 @@
|
|||||||
"updated_text": "Hoppscotch has been updated to v{version} 🎉",
|
"updated_text": "Hoppscotch has been updated to v{version} 🎉",
|
||||||
"whats_new": "What's new?",
|
"whats_new": "What's new?",
|
||||||
"see_whats_new": "See what’s new",
|
"see_whats_new": "See what’s new",
|
||||||
"wiki": "Wiki"
|
"wiki": "Wiki",
|
||||||
|
"default": "default: {value}"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"account_exists": "Account exists with different credential - Login to link both accounts",
|
"account_exists": "Account exists with different credential - Login to link both accounts",
|
||||||
|
|||||||
@@ -246,6 +246,22 @@ const selectOAuth2AuthType = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectAPIKeyAuthType = () => {
|
||||||
|
auth.value = {
|
||||||
|
...auth.value,
|
||||||
|
authType: "api-key",
|
||||||
|
addTo: "HEADERS",
|
||||||
|
} as HoppGQLAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectAWSSignatureAuthType = () => {
|
||||||
|
auth.value = {
|
||||||
|
...auth.value,
|
||||||
|
authType: "aws-signature",
|
||||||
|
addTo: "HEADERS",
|
||||||
|
} as HoppGQLAuth
|
||||||
|
}
|
||||||
|
|
||||||
const authTypes: AuthType[] = [
|
const authTypes: AuthType[] = [
|
||||||
{
|
{
|
||||||
key: "inherit",
|
key: "inherit",
|
||||||
@@ -271,10 +287,12 @@ const authTypes: AuthType[] = [
|
|||||||
{
|
{
|
||||||
key: "api-key",
|
key: "api-key",
|
||||||
label: "API Key",
|
label: "API Key",
|
||||||
|
handler: selectAPIKeyAuthType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "aws-signature",
|
key: "aws-signature",
|
||||||
label: "AWS Signature",
|
label: "AWS Signature",
|
||||||
|
handler: selectAWSSignatureAuthType,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -591,6 +591,7 @@ const getComputedAuthHeaders = async (
|
|||||||
region: request.auth.region ?? "us-east-1",
|
region: request.auth.region ?? "us-east-1",
|
||||||
service: request.auth.serviceName,
|
service: request.auth.serviceName,
|
||||||
url,
|
url,
|
||||||
|
sessionToken: request.auth.serviceToken,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sign = await signer.sign()
|
const sign = await signer.sign()
|
||||||
|
|||||||
@@ -170,20 +170,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import IconHelpCircle from "~icons/lucide/help-circle"
|
|
||||||
import IconTrash2 from "~icons/lucide/trash-2"
|
|
||||||
import IconExternalLink from "~icons/lucide/external-link"
|
|
||||||
import IconCircleDot from "~icons/lucide/circle-dot"
|
|
||||||
import IconCircle from "~icons/lucide/circle"
|
|
||||||
import { computed, ref } from "vue"
|
|
||||||
import { HoppRESTAuth, HoppRESTAuthOAuth2 } from "@hoppscotch/data"
|
|
||||||
import { pluckRef } from "@composables/ref"
|
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
|
import { pluckRef } from "@composables/ref"
|
||||||
import { useColorMode } from "@composables/theming"
|
import { useColorMode } from "@composables/theming"
|
||||||
import { useVModel } from "@vueuse/core"
|
import { useVModel } from "@vueuse/core"
|
||||||
import { onMounted } from "vue"
|
import { computed, onMounted, ref } from "vue"
|
||||||
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
import { HoppInheritedProperty } from "~/helpers/types/HoppInheritedProperties"
|
||||||
import { AggregateEnvironment } from "~/newstore/environments"
|
import { AggregateEnvironment } from "~/newstore/environments"
|
||||||
|
import IconCircle from "~icons/lucide/circle"
|
||||||
|
import IconCircleDot from "~icons/lucide/circle-dot"
|
||||||
|
import IconExternalLink from "~icons/lucide/external-link"
|
||||||
|
import IconHelpCircle from "~icons/lucide/help-circle"
|
||||||
|
import IconTrash2 from "~icons/lucide/trash-2"
|
||||||
|
|
||||||
import { getDefaultAuthCodeOauthFlowParams } from "~/services/oauth/flows/authCode"
|
import { getDefaultAuthCodeOauthFlowParams } from "~/services/oauth/flows/authCode"
|
||||||
|
|
||||||
@@ -228,6 +226,22 @@ type AuthType = {
|
|||||||
handler?: () => void
|
handler?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectAPIKeyAuthType = () => {
|
||||||
|
auth.value = {
|
||||||
|
...auth.value,
|
||||||
|
authType: "api-key",
|
||||||
|
addTo: "HEADERS",
|
||||||
|
} as HoppRESTAuth
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectAWSSignatureAuthType = () => {
|
||||||
|
auth.value = {
|
||||||
|
...auth.value,
|
||||||
|
authType: "aws-signature",
|
||||||
|
addTo: "HEADERS",
|
||||||
|
} as HoppRESTAuth
|
||||||
|
}
|
||||||
|
|
||||||
const authTypes: AuthType[] = [
|
const authTypes: AuthType[] = [
|
||||||
{
|
{
|
||||||
key: "inherit",
|
key: "inherit",
|
||||||
@@ -253,10 +267,12 @@ const authTypes: AuthType[] = [
|
|||||||
{
|
{
|
||||||
key: "api-key",
|
key: "api-key",
|
||||||
label: "API Key",
|
label: "API Key",
|
||||||
|
handler: selectAPIKeyAuthType,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "aws-signature",
|
key: "aws-signature",
|
||||||
label: "AWS Signature",
|
label: "AWS Signature",
|
||||||
|
handler: selectAWSSignatureAuthType,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,10 @@
|
|||||||
<SmartEnvInput
|
<SmartEnvInput
|
||||||
v-model="auth.region"
|
v-model="auth.region"
|
||||||
:auto-complete-env="true"
|
:auto-complete-env="true"
|
||||||
:placeholder="t('authorization.aws_signature.aws_region')"
|
:placeholder="`${t('authorization.aws_signature.aws_region')} (${t(
|
||||||
|
'app.default',
|
||||||
|
{ value: 'us-east-1' }
|
||||||
|
)})`"
|
||||||
:envs="envs"
|
:envs="envs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,7 +55,8 @@
|
|||||||
:envs="envs"
|
:envs="envs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center !border-b border-dividerLight">
|
|
||||||
|
<div class="flex items-center border-b border-dividerLight">
|
||||||
<span class="flex items-center">
|
<span class="flex items-center">
|
||||||
<label class="ml-4 text-secondaryLight">
|
<label class="ml-4 text-secondaryLight">
|
||||||
{{ t("authorization.pass_key_by") }}
|
{{ t("authorization.pass_key_by") }}
|
||||||
@@ -61,17 +65,11 @@
|
|||||||
interactive
|
interactive
|
||||||
trigger="click"
|
trigger="click"
|
||||||
theme="popover"
|
theme="popover"
|
||||||
:on-shown="() => authTippyActions.focus()"
|
:on-shown="() => authTippyActions?.focus()"
|
||||||
>
|
>
|
||||||
<HoppSmartSelectWrapper>
|
<HoppSmartSelectWrapper>
|
||||||
<HoppButtonSecondary
|
<HoppButtonSecondary
|
||||||
:label="
|
:label="passBy"
|
||||||
auth.addTo
|
|
||||||
? auth.addTo === 'HEADERS'
|
|
||||||
? t('authorization.pass_by_headers_label')
|
|
||||||
: t('authorization.pass_by_query_params_label')
|
|
||||||
: t('state.none')
|
|
||||||
"
|
|
||||||
class="ml-2 rounded-none pr-8"
|
class="ml-2 rounded-none pr-8"
|
||||||
/>
|
/>
|
||||||
</HoppSmartSelectWrapper>
|
</HoppSmartSelectWrapper>
|
||||||
@@ -83,25 +81,16 @@
|
|||||||
@keyup.escape="hide()"
|
@keyup.escape="hide()"
|
||||||
>
|
>
|
||||||
<HoppSmartItem
|
<HoppSmartItem
|
||||||
:icon="auth.addTo === 'HEADERS' ? IconCircleDot : IconCircle"
|
v-for="addToTarget in addToTargets"
|
||||||
:active="auth.addTo === 'HEADERS'"
|
:key="addToTarget.id"
|
||||||
:label="t('authorization.pass_by_headers_label')"
|
:label="addToTarget.label"
|
||||||
@click="
|
|
||||||
() => {
|
|
||||||
auth.addTo = 'HEADERS'
|
|
||||||
hide()
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
<HoppSmartItem
|
|
||||||
:icon="
|
:icon="
|
||||||
auth.addTo === 'QUERY_PARAMS' ? IconCircleDot : IconCircle
|
auth.addTo === addToTarget.id ? IconCircleDot : IconCircle
|
||||||
"
|
"
|
||||||
:active="auth.addTo === 'QUERY_PARAMS'"
|
:active="auth.addTo === addToTarget.id"
|
||||||
:label="t('authorization.pass_by_query_params_label')"
|
|
||||||
@click="
|
@click="
|
||||||
() => {
|
() => {
|
||||||
auth.addTo = 'QUERY_PARAMS'
|
auth.addTo = addToTarget.id
|
||||||
hide()
|
hide()
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
@@ -115,13 +104,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import IconCircle from "~icons/lucide/circle"
|
|
||||||
import IconCircleDot from "~icons/lucide/circle-dot"
|
|
||||||
import { useI18n } from "@composables/i18n"
|
import { useI18n } from "@composables/i18n"
|
||||||
import { HoppRESTAuthAWSSignature } from "@hoppscotch/data"
|
import { HoppRESTAuthAWSSignature } from "@hoppscotch/data"
|
||||||
import { useVModel } from "@vueuse/core"
|
import { useVModel } from "@vueuse/core"
|
||||||
|
import { computed, ref } from "vue"
|
||||||
import { AggregateEnvironment } from "~/newstore/environments"
|
import { AggregateEnvironment } from "~/newstore/environments"
|
||||||
import { ref } from "vue"
|
import IconCircle from "~icons/lucide/circle"
|
||||||
|
import IconCircleDot from "~icons/lucide/circle-dot"
|
||||||
|
|
||||||
const t = useI18n()
|
const t = useI18n()
|
||||||
|
|
||||||
@@ -137,4 +126,22 @@ const emit = defineEmits<{
|
|||||||
const auth = useVModel(props, "modelValue", emit)
|
const auth = useVModel(props, "modelValue", emit)
|
||||||
|
|
||||||
const authTippyActions = ref<any | null>(null)
|
const authTippyActions = ref<any | null>(null)
|
||||||
|
|
||||||
|
const addToTargets = [
|
||||||
|
{
|
||||||
|
id: "HEADERS" as const,
|
||||||
|
label: "Headers",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "QUERY_PARAMS" as const,
|
||||||
|
label: "Query Params",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
const passBy = computed(() => {
|
||||||
|
return (
|
||||||
|
addToTargets.find((target) => target.id === auth.value.addTo)?.label ||
|
||||||
|
t("state.none")
|
||||||
|
)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -288,7 +288,8 @@ export const runGQLOperation = async (options: RunQueryOptions) => {
|
|||||||
params[key] = value
|
params[key] = value
|
||||||
}
|
}
|
||||||
} else if (auth.authType === "aws-signature") {
|
} else if (auth.authType === "aws-signature") {
|
||||||
const { accessKey, secretKey, region, serviceName, addTo } = auth
|
const { accessKey, secretKey, region, serviceName, addTo, serviceToken } =
|
||||||
|
auth
|
||||||
|
|
||||||
const currentDate = new Date()
|
const currentDate = new Date()
|
||||||
const amzDate = currentDate.toISOString().replace(/[:-]|\.\d{3}/g, "")
|
const amzDate = currentDate.toISOString().replace(/[:-]|\.\d{3}/g, "")
|
||||||
@@ -301,6 +302,7 @@ export const runGQLOperation = async (options: RunQueryOptions) => {
|
|||||||
region: region ?? "us-east-1",
|
region: region ?? "us-east-1",
|
||||||
service: serviceName,
|
service: serviceName,
|
||||||
url,
|
url,
|
||||||
|
sessionToken: serviceToken,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sign = await signer.sign()
|
const sign = await signer.sign()
|
||||||
|
|||||||
@@ -146,6 +146,9 @@ export const getComputedAuthHeaders = async (
|
|||||||
region:
|
region:
|
||||||
parseTemplateString(request.auth.region, envVars) ?? "us-east-1",
|
parseTemplateString(request.auth.region, envVars) ?? "us-east-1",
|
||||||
service: parseTemplateString(request.auth.serviceName, envVars),
|
service: parseTemplateString(request.auth.serviceName, envVars),
|
||||||
|
sessionToken:
|
||||||
|
request.auth.serviceToken &&
|
||||||
|
parseTemplateString(request.auth.serviceToken, envVars),
|
||||||
url: parseTemplateString(endpoint, envVars),
|
url: parseTemplateString(endpoint, envVars),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -290,6 +293,9 @@ export const getComputedParams = async (
|
|||||||
secretAccessKey: parseTemplateString(req.auth.secretKey, envVars),
|
secretAccessKey: parseTemplateString(req.auth.secretKey, envVars),
|
||||||
region: parseTemplateString(req.auth.region, envVars) ?? "us-east-1",
|
region: parseTemplateString(req.auth.region, envVars) ?? "us-east-1",
|
||||||
service: parseTemplateString(req.auth.serviceName, envVars),
|
service: parseTemplateString(req.auth.serviceName, envVars),
|
||||||
|
sessionToken:
|
||||||
|
req.auth.serviceToken &&
|
||||||
|
parseTemplateString(req.auth.serviceToken, envVars),
|
||||||
url: parseTemplateString(req.endpoint, envVars),
|
url: parseTemplateString(req.endpoint, envVars),
|
||||||
})
|
})
|
||||||
const sign = await signer.sign()
|
const sign = await signer.sign()
|
||||||
|
|||||||
Reference in New Issue
Block a user