wso2 / wso2/docs-apim

Doc Feedback: Misuse of Authorization Header in Custom Authentication Handler Example

Open
#10,559 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

API-M-4.5.0
Dominant language
CSS
Stars
99
Forks
708
Avg merge
1d 7h
Merged PRs (30d)
22

Description

Location : https://apim.docs.wso2.com/en/4.5.0/reference/customize-product/extending-api-manager/extending-gateway/writing-custom-handlers/

Summary

The current documentation example for a custom API authentication handler uses the HTTP Authorization header to pass a plain username (e.g., Authorization: userName:xxx). This is not a valid or real-world authentication pattern and may mislead users into implementing insecure or non-standard solutions.

Problem Description

The documented example validates requests using logic similar to: Authorization: userName:janaka

This approach has several issues:

❌ Violates HTTP and OAuth2 standards
❌ Misuses the Authorization header, which is reserved for authentication schemes such as Bearer, Basic, etc.
❌ Can confuse users about recommended APIM security practices

In real-world systems, usernames are never sent in plain text via the Authorization header.

Why This Is an Issue

Developers may assume this is an acceptable production pattern
Encourages insecure implementations
Reduces documentation credibility

Proposed Improvement (Recommended)

If the intention of the example is to demonstrate custom request validation logic, the example should:

✅ Use a custom HTTP header instead of Authorization

Example:

X-User-Name: janaka

This:

  • Keeps Authorization semantics intact
  • Clearly signals that this is not authentication
  • Aligns with common industry practices
  • Avoids security misconceptions

Suggested Documentation Changes

  1. Update Code Example
private String getUserNameHeader(Map headers) {
    return (String) headers.get("X-User-Name");
}

if (userName != null && !userName.isEmpty()) {
    return true;
}
  1. Update Sample curl Command
curl -X GET http://localhost:8280/sample/1.0.0/test \
  -H "X-User-Name: janaka"
  1. Add a Clear Note in Documentation

Note: This example is for demonstrating custom handler mechanics only.
It is not a replacement for OAuth2/JWT-based authentication, which is the recommended approach for production APIs.

Requested Action

Update the example to use a custom header
Add a clarification note about real-world authentication
Avoid using the Authorization header for non-standard purposes

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the linked custom authentication handler documentation page and locate the Java example and sample curl command that use the Authorization header. Update the example to use X-User-Name, add the requested production-authentication clarification, and verify the page no longer presents the plain username header as an authentication pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, authentication, documentation, security
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.