Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add basic auth header in autobahn client tool

I want to add basic auth header in the autobahn client tool. How can I achieve that?

Current request

GET / HTTP/1.1  
User-Agent: AutobahnPython/0.5.2  
Host: 10.35.34.172:9000  
Upgrade: WebSocket  
Connection: Upgrade  
Sec-WebSocket-Key: 1U4OeBs60qkmk1V/8voLOw==  
Sec-WebSocket-Version: 8  

Request I need:

GET / HTTP/1.1  
User-Agent: AutobahnPython/0.5.2  
Host: 10.35.34.172:9000  
Authorization: Basic TXlMb2NhdGlvbkFwcDpNeUxvY2F0aW9uQXBwMTIz  
Upgrade: WebSocket  
Connection: Upgrade  
Sec-WebSocket-Key: 1U4OeBs60qkmk1V/8voLOw==  
Sec-WebSocket-Version: 8  

Note: I don't want autobahn server to authenticate the client.
My scenario is autobahn client --> my server --> autobahn server.
My server will take care of extracting the authorization header and then invoke the autobahn server.

like image 396
vinbha Avatar asked Apr 24 '13 09:04

vinbha


People also ask

What is authorization header in HTTP?

The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a protected resource. The Authorization header is usually, but not always, sent after the user agent first attempts to request a protected resource without credentials.


1 Answers

I have implemented options to send custom HTTP headers for both AutobahnPython client and server. You need to use the latest AutobahnPython on GitHub (master branch).

A client can send headers by providing a headers keyword argument during construction of the WebSocketClientFactory or set headers via setSessionParameters.

A server can send headers similar to client, and additionally specify headers when returning from onConnect.

Here is a complete example.

Disclaimer: I am original author of Autobahn and work for Tavendo.

like image 197
oberstet Avatar answered Sep 18 '22 16:09

oberstet