Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for Digest authorization #4339

Merged
merged 21 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: clean up
  • Loading branch information
anwarulislam authored and jamesgeorge007 committed Oct 29, 2024
commit 3c5ad34aa97b0027d6a3ad3e0bc9e721797c26a5
6 changes: 4 additions & 2 deletions packages/hoppscotch-common/src/helpers/auth/digest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface DigestAuthParams {
password: string
realm: string
nonce: string
uri: string
endpoint: string
method: string
algorithm: string
qop: string
Expand All @@ -25,7 +25,7 @@ export async function generateDigestAuthHeader(params: DigestAuthParams) {
password,
realm,
nonce,
uri,
endpoint,
method,
algorithm = "MD5",
qop,
Expand All @@ -34,6 +34,8 @@ export async function generateDigestAuthHeader(params: DigestAuthParams) {
cnonce,
} = params

const uri = endpoint.replace(/(^\w+:|^)\/\//, "")

// Generate client nonce if not provided
const generatedCnonce = cnonce || md5(`${Math.random()}`)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export const getComputedAuthHeaders = async (
nonce: request.auth.nonce
? parseTemplateString(authInfo.nonce, envVars)
: authInfo.nonce,
uri: parseTemplateString(endpoint, envVars),
endpoint: parseTemplateString(endpoint, envVars),
method,
algorithm: request.auth.algorithm ?? authInfo.algorithm,
qop: request.auth.qop
Expand Down