Best practice to handle passwords/keys in python - python

I am developing a client and a server in python. The client connects to the server and send requests for the server to perform specific tasks. In one of the tasks the server needs to connect to a ssh server using a private key. Is there any good way to store this private key? Should it be stored in the client or in the server? If stored in the client, what would be the safe way to send it to the server when needed? I don't really want to have the need to type a password in the client everytime.
Thanks.

Related

How to let server send the message first in GRPC using python

Hi i am new to GRPC and i want to send one message from server to client first. I understood how to implement client sending a message and getting response from server. But i wanna try how server could initiate a message to connected clients. How could i do that?
Short answer: you can't
gRPC is a request-response framework based on HTTP2. Just as you cannot make a website that initiates a connection to a browser, you cannot make a gRPC service initiating a connection to the client. How would the service even know who to talk to?
A solution could be to open a gRPC server on the client. This way both the client and the server can accept connections from one another.

django save websocket to redis without closing it

Is there a way to keep websocket open using redis for future use ?
I need my django server to communicate with a websocket backend service on behalf of the client.
It means that I need to save the websocket open between multiple http requests of the client.
can I use redis for this purpose or is there any other way to do so ?
Thanks.

Restrict Python API access to single Arduino entity

I am basically writing an API in Python, using Flask, and I would like to restrict access to its endpoints so that only an entity, namely an Arduino, can have GET and POST access. How should I make this possible and what should I be looking for?
You can assign a secret key (i.e. a password) to each client of this API, and then require that this key is provided by the client with all requests sent to the server.
So you start by assigning a key to your Arduino client, but you can also give a different key to your own testing client, and any other development clients you may need.
The secret key can be passed as HTTP Basic Authentication with every request.
Configure your WSGI container or its associated web server to only allow access to the Flask application from the IP address assigned to the Arduino's network interface.

Push notifications from web server to desktop app in python

I have a service with users (in django) and desktop client for this srevice (on wxpython). I need to send notifications from server to desktop app for specific user.
What I can use for it?
Thank you!
I don't know wxPython, but if you want to use long-polling, comet or another technique based on HTTP protocol, then you need to write HTTP client or use any network framework.
For example Twisted.
Make connection to your django server and send data through TCP transport using HTTP protocol.

How to maintain server-initiated FTP connection between client requests in Python/Django?

I'm going to use ftplib to open up an FTP connection to an FTP server provided by the user. The client will be sending FTP commands to my django server via Ajax, which will then be forwarded to the FTP server the user provided. However, I'd like to not have to create a new FTP server connection every time the client sends an FTP command. In other words, I want to keep the FTP connection alive between requests by the client.
How would I do this? Would some sort of comet implementation be best? I was initially planning to use WebSockets until I discovered my host won't allow it. =\
You'll need to use a persistent connection framework as what you're trying to achieve really isn't what HTTP was meant for (in the sense that HTTP commands are stateless and independent), and thus not what Django is built for. There are a number of options, but since it seems you are in a restricted environment you'll need to do some research to determine what's best.
Switch hosts. Webfaction allows websockets with dedicated IP at around $20 per month.

Categories

Resources