0

I am using Twisted/Klein to create an API over UNIX-domain sockets for some command-line services I am writing. I would like to be able to get access to the socket object so that I can check the PEER CREDENTIALS for that socket to determine who has access to which methods of the API. Does anyone know of a way to access that socket object or, alternately, access the PEER CREDENTIALS data from a UNIX-domain socket in Klein/Twisted?

Thanks in advance!!

Deven Phillips
  • 1,129
  • 14
  • 39

1 Answers1

1

In Klein, it would be request.channel.transport.getHandle().

The types of these objects are, respectively:

twisted.web.server.Request, twisted.web.http.HTTPChannel, twisted.internet.unix.Server, and socket.socket, respectively.

Glyph
  • 31,152
  • 11
  • 87
  • 129
  • You may also be interested in this ticket - https://twistedmatrix.com/trac/ticket/8191 - where we were thinking of deprecating these attributes. This question is prompting me to consider whether we still need to provide access to the transport at some level, or this should be accomplished in some other way (like having a custom `requestFactory`) – Glyph Feb 23 '16 at 19:40
  • Perhaps kwargs with the specifics from the socket would be sufficient? – Deven Phillips Feb 23 '16 at 20:23