Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ CLOUD:
AUTHENTICATION:
-sf, -secret-file string[] path to config file containing secrets for nuclei authenticated scan
-ps, -prefetch-secrets prefetch secrets from the secrets file
# NOTE: Headers in secrets files preserve exact casing (useful for case-sensitive APIs)


EXAMPLES:
Expand Down
4 changes: 4 additions & 0 deletions SYNTAX-REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,8 @@ be provided as payload which will be read on run-time.

Headers contains HTTP Headers to send with the request.

**Note:** When using headers in authentication secrets files (via `-sf` flag), header names preserve exact casing (e.g., `barAuthToken` stays as `barAuthToken`). This is useful for APIs that require case-sensitive header names. Template headers are canonicalized by default.



Examples:
Expand Down Expand Up @@ -1424,6 +1426,8 @@ Valid values:

SkipSecretFile skips the authentication or authorization configured in the secret file.

**Note:** Authentication secrets files preserve exact header casing, which is useful for case-sensitive APIs.

</div>

<hr />
Expand Down
4 changes: 2 additions & 2 deletions pkg/authprovider/authx/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Secret struct {
Type string `json:"type" yaml:"type"`
Domains []string `json:"domains" yaml:"domains"`
DomainsRegex []string `json:"domains-regex" yaml:"domains-regex"`
Headers []KV `json:"headers" yaml:"headers"`
Headers []KV `json:"headers" yaml:"headers"` // Headers preserve exact casing (useful for case-sensitive APIs)
Cookies []Cookie `json:"cookies" yaml:"cookies"`
Params []KV `json:"params" yaml:"params"`
Username string `json:"username" yaml:"username"` // can be either email or username
Expand Down Expand Up @@ -148,7 +148,7 @@ func (s *Secret) Validate() error {
}

type KV struct {
Key string `json:"key" yaml:"key"`
Key string `json:"key" yaml:"key"` // Header key (preserves exact casing)
Value string `json:"value" yaml:"value"`
}

Expand Down
8 changes: 6 additions & 2 deletions pkg/authprovider/authx/headers_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ func NewHeadersAuthStrategy(data *Secret) *HeadersAuthStrategy {
}

// Apply applies the headers auth strategy to the request
// NOTE: This preserves exact header casing (e.g., barAuthToken stays as barAuthToken)
// This is useful for APIs that require case-sensitive header names
func (s *HeadersAuthStrategy) Apply(req *http.Request) {
for _, header := range s.Data.Headers {
req.Header.Set(header.Key, header.Value)
req.Header[header.Key] = []string{header.Value}
}
}

// ApplyOnRR applies the headers auth strategy to the retryable request
// NOTE: This preserves exact header casing (e.g., barAuthToken stays as barAuthToken)
// This is useful for APIs that require case-sensitive header names
func (s *HeadersAuthStrategy) ApplyOnRR(req *retryablehttp.Request) {
for _, header := range s.Data.Headers {
req.Header.Set(header.Key, header.Value)
req.Header[header.Key] = []string{header.Value}
}
}
4 changes: 4 additions & 0 deletions pkg/authprovider/authx/testData/example-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ info:
# static secrets
static:
# for header based auth session
# NOTE: Headers preserve exact casing (e.g., x-pdcp-key stays as x-pdcp-key)
# This is useful for APIs that require case-sensitive header names
- type: header
domains:
- api.projectdiscovery.io
Expand All @@ -20,6 +22,8 @@ static:
headers:
- key: x-pdcp-key
value: <api-key-here>
- key: barAuthToken
value: <auth-token-here>

# for query based auth session
- type: Query
Expand Down
Loading