Skip to content

Commit ee08181

Browse files
Add auth header forwarding in nginx proxy configuration
1 parent c9e3daf commit ee08181

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

registry/core/nginx_service.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ async def generate_config_async(self, servers: Dict[str, Dict[str, Any]]) -> boo
118118
# Authenticate request - pass entire request to auth server
119119
auth_request /validate;
120120
121+
# Capture auth server response headers for forwarding
122+
auth_request_set $auth_user $upstream_http_x_user;
123+
auth_request_set $auth_username $upstream_http_x_username;
124+
auth_request_set $auth_client_id $upstream_http_x_client_id;
125+
auth_request_set $auth_scopes $upstream_http_x_scopes;
126+
auth_request_set $auth_method $upstream_http_x_auth_method;
127+
auth_request_set $auth_server_name $upstream_http_x_server_name;
128+
auth_request_set $auth_tool_name $upstream_http_x_tool_name;
129+
121130
# Proxy to MCP server
122131
proxy_pass {proxy_pass_url};
123132
proxy_http_version 1.1;
@@ -135,6 +144,15 @@ async def generate_config_async(self, servers: Dict[str, Dict[str, Any]]) -> boo
135144
proxy_set_header X-Client-Id $http_x_client_id;
136145
proxy_set_header X-Region $http_x_region;
137146
147+
# Forward auth server response headers to backend
148+
proxy_set_header X-User $auth_user;
149+
proxy_set_header X-Username $auth_username;
150+
proxy_set_header X-Client-Id-Auth $auth_client_id;
151+
proxy_set_header X-Scopes $auth_scopes;
152+
proxy_set_header X-Auth-Method $auth_method;
153+
proxy_set_header X-Server-Name $auth_server_name;
154+
proxy_set_header X-Tool-Name $auth_tool_name;
155+
138156
# For SSE connections and WebSocket upgrades
139157
proxy_buffering off;
140158
proxy_cache off;

0 commit comments

Comments
 (0)