Where to get the CherryPy auth_digest module? - python

I have a CherryPy web site running on a virtual ubuntu linux server. I'm attempting to move the application to a second, larger-memory server. Both servers appears to have CherryPy 3.2 installed (I just used apt-get to install it on the newer server).
The newer server, however, does not appear to have the CherryPy auth_digest module installed which is what I'm using for authentication. It is present in the CherryPy egg on the older server.
How can I update my copy of CherryPy to incorporate that module?

I wound up downloading the tar file (which I think may be a minor version or two more recent than what apt-get knows about) and using setup.py to install it. This version includes the digest authorization module.

Related

Azure App Service ImportError: libmysqlclient.so.18: cannot open shared object file: No such file or directory

On App Azure Linux with Python, the Mysql module seem not work :
2018-12-24T19:11:38.215760010Z import _mysql
2018-12-24T19:11:38.215763810Z ImportError: libmysqlclient.so.18: cannot
open shared object file: No such file or directory
...
2018-12-24T19:11:27.536810347Z django.core.exceptions.ImproperlyConfigured:
Error loading MySQLdb module.
2018-12-24T19:11:27.536813747Z Did you install mysqlclient?
requirement :
django
mysqlclient
Has anyone ever managed to run django on azure web app?
This is a common error. Using mysqlclient also requires native dependencies to be installed: either the mysql client or the mysql-compatible mariadb client. In order to address these issues the easiest way, change your project to use mysql-connector-python instead of mysqlclient. You will also have to update your settings so that any database engine that uses django.db.backends.mysql should be updated to mysql.connector.django.
It sounds like there is not mysql native client library installed in your Azure App for Linux.
Here is two cases for building custom image.
For Debian or Ubuntu image, please run apt install libmysqlclient-dev firstly to preinstall libmysqlclient.so on your Docker image.
For Fedora or CentOS iamge, please run yum install mysql-libs firstly to preinstall the same one.
Or you can directly use the existing image which has preinstalled these required libs from Azure Container Registry or DockerHub.
Please take a try that go to the app service scm site, and find the pip location, then use pip to install the required module.

Python flask saml throwing saml2.sigver.SigverError Error Message

Has anyone succesfully implemented flask-saml using Windows as dev environment, Python 3.6 and Flask 1.0.2?
I was given the link to the SAML METADATA XML file by our organisation and had it configured on my flask app.
app.config.update({
'SECRET_KEY': 'changethiskeylaterthisisoursecretkey',
'SAML_METADATA_URL': 'https://<url>/FederationMetadata.xml',
})
flask_saml.FlaskSAML(app)
According to the documentation this extension will setup the following routes:
/saml/logout/: Log out from the application. This is where users go
if they click on a “Logout” button.
/saml/sso/: Log in through SAML.
/saml/acs/: After /saml/sso/ has sent you to your IdP it sends you
back to this path. Also your IdP might provide direct login without
needing the /saml/sso/ route.
When I go to one of the routes http://localhost:5000/saml/sso/ I get the error below
saml2.sigver.SigverError saml2.sigver.SigverError: Cannot find
['xmlsec.exe', 'xmlsec1.exe']
I then went to this site https://github.com/mehcode/python-xmlsec/releases/tag/1.3.5 to get xmlsec and install it. However, I'm still getting the same issue.
Here is a screenshot of how I installed xmlsec
where does not seem to find the xmlsec.exe
documentationis asking to have xmlsec1 pre-installed. What you installed is a python binding to xmlsec1.
Get a windows build of xmlsec1 from here or build it from source
And make it available in the PATH.
xmlsec won't work properly in windows, better use Linux environment
Type the below command before giving pip install xmlsec
sudo apt-get install xmlsec1

Is it a security issue to pin the version of the "certifi" package in requirements.txt?

I have a web service that uses the requests library to make https requests to a different, external service.
As part of my deployment process, whenever there's a change to the list of dependencies, I use pip freeze to regenerate the requirements.txt file, which is stored in my code repository and processed by my PaaS provider to set up the application environment.
Today, I noticed this line in my requirements.txt file:
certifi==14.05.14
That is, the certifi package is pinned down to a version that is no longer the latest.
Is this a security issue (does it mean that my trusted root certificates are not up-to-date)?
If so - what would be the best way to change my deployment process (which is, I think, fairly standard) to solve this issue?

How to 'pip install packages' inside Azure WebJob to resolve package compatibility issues

I am deploying a WebJob inside Azure Web App that uses Google Maps API and Azure SQL Storage.
I am following the typical approach where I make a WebJob directory and copy my 'site-packages' folder inside the root folder of the WebJob. Then I also add my code folder inside 'site-packages' and make a run.py file inside the root that looks like this:
import sys, os
sys.path.append(os.path.join(os.getcwd(), "site-packages"))
import aero2.AzureRoutine as aero2
aero2.run()
Now the code runs correctly in Azure. But I am seeing warnings after a few commands which slow down my code.
I have tried copying 'pyopenSSL' and 'requests' module into my site-packages folder, but the error persists.
However, the code runs perfectly on my local machine.
How can I find this 'pyopenSSL' or 'requests' that is compatible with the python running on Azure?
Or
How can I modify my code so that it pip installs the relevant packages for the python running on Azure?
Or more importantly,
How can I resolve this error?
#Saad,
If your webjob worked fine on Azure Web App, but you got inscuritywaring, I suggest you can try to disable the warning information via this configuration(https://urllib3.readthedocs.org/en/latest/security.html#disabling-warnings ).
Meanwhile,requests lib has some different with the high version, I recommend you refer to this document:
http://fossies.org/diffs/requests/2.5.3_vs_2.6.0/requests/packages/urllib3/util/ssl_.py-diff.html
And Azure web app used the Python 2.7.8 version which is lower than 2.7.9. So you can download the requests lib as version 2.5.3
According the doc referred in the warning message https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning:
Certain Python platforms (specifically, versions of Python earlier than 2.7.9) have restrictions in their ssl module that limit the configuration that urllib3 can apply. In particular, this can cause HTTPS requests that would succeed on more featureful platforms to fail, and can cause certain security features to be unavailable.
So the easiest way fix this warning, is to upgrade the python version of the Azure Web Apps. Login the Azure manager portal, change the python version to 3.4 in Application settings column:
As I test in webjob task to use requests module to request a "https://" url, and since upgrade python version to 3.4, there are no more warnings.
I followed this article and kind of 'pip installed' the pymongo library for my script. Not sure if it works for you but here are the steps:
Make sure you include the library name and version in the requirements.txt
Deploy the web app using Git. The directory should include at least
requirements.txt (only to install whatever is in requirements.txt in the virtual environment, which is shared with Web App in D:\home\site\wwwroot\env\Lib\site-packages)
add this block of code to the Python code you want to use in the WebJob zip file.
import sys
sitepackage = "D:\home\site\wwwroot\env\Lib\site-packages"
sys.path.append(sitepackage)

Parallel Python install on Media Temple DV server

Plesk on the MediaTemple DV servers uses Python 2.4 for stuff, so the 2.4 install can't be replaced but someone recommended installing a separate python 2.7 install since my app runs on that. I'm new to the whole server thing, so this is new territory. My sense is that I can create a new directory for the source files and use SSH to download the files to said directory and then cd into it and install python 2.7. Then I have to figure out how to make sure Apache knows to use Python 2.7 to run the django app in question. Does this sound correct?
Unless you can make a system wide change to your python installation, you would have to run Apache, python and Django in the same virtual environment. If it is not possible, use gunicorn (instead of apache) to run the Django app in a virtualenv (in a port different from Apache's). If this app runs in a subdomain, you should consider hosting the Django app in a PAAS (Heroku, Google App Engine, etc.) which allow you to easily switch running environments.
Never mind, sorted it. the important thing seemed to be to edit the etc/ld.so.conf by adding usr/local/lib, then running sbin/ldconfig, which then makes ld.so.conf look like:
include ld.so.conf.d/*.conf
/usr/local/lib
Donwload and then compile Python
and use make && make altinstall.

Categories