Python flask saml throwing saml2.sigver.SigverError Error Message - python

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

Related

Cannot install packages for Python Azure Function

I have a Python Azure function which executes locally. It is deployed to Azure and I selected the 'free app plan'. The Python has dependencies on various modules, such as requests. The modules are not loaded into the app like they are locally on my machine. The function fails when triggered.
I have tried installing the dependencies using Kudu console from my site, this hangs with message cleaning up >> every time.
I have tried installing the dependencies using SSH terminal from my site, the installations succeed but i cannot see the modules when python pip list in kudo and the app still fails. I cannot navigate the directories ls does nothing.
I tried to install extensions using the portal but this option is greyed out in development-tools.
You can find a requirements.txt in your local function folder.
If you want function on azure to install the 'requests', your requirements.txt should be like this:(Azure will install the extension based on this file)
azure-functions
requests
And all these packages will be packaged into a new package on Azure, so you can not display which packages using pip list. Also, please keep in mind that Linux's Kudu feature is limited and you cannot install packages through it.
Problem seems comes from VS Code, you can use command to deploy your function app.
For example, my functionapp on Azure named 423PythonBowman2, So this is my command:
func azure functionapp publish 423PythonBowman --build remote
I quoted requests in the code, and with cmd deploy my function can works fine on portal with no errors.
Have a look of the offcial doc:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Ccsharp%2Cbash#publish

Swagger-codegen flask generated server locally doesn't works

I have generated a simple API server example using swaggerhub, and downloaded python-flask generated server locally.
Unfortunately, it seems to not work at all. Every time I try to access the indicated url, that is
http://localhost:8080/data/2.5//ui/
it returns me a 404 error.
I've tried all the solutions reported on:
Python connexion not displaying Swagger UI
but with no success. What am I missing?
A very simple detail that made all work: after executing pip install 'connexion[swagger-ui]' and pip install pathlib swagger_ui_bundle (though I am not sure the last is strictly needed...), the server worked only with an invalidate cache and restart command on PyCharm.

How to create an Azure Artifacts public feed to make it possible to pip install the nightly builds of an open source project without credentials?

I created a new artifact feed from a public open source project that is already being used to perform Azure Pipelines public CI on a repo hosted on github.
I successfully uploaded a bunch of test Python wheel files to that feed using twine and the appropriate credentials.
The generated pip feed URL looks as follows:
https://pkgs.dev.azure.com/orgname/publicprojectname/_packaging/feedname/pypi/simple/
If I type the "pypi"/"pip" URL of the feed in the browser where I am logged in, I get the following message:
This functionality is currently not available.
If I type the same URL in a new "private browsing" window on firefox, I get redirected to the Azure login page.
My end goal would be to share nightly builds and I do not want to use the main pypi.org server for that.
Note: this official tutorial mentions a specific button named "+ New public feed (preview)" to create the feed but I could not find it on my project. I used the regular "+ New feed" button instead. Maybe this is the cause of the problem?
Even if the URL cannot be browsed from a regular browser, pointing pip to use it with the following command works as expected:
pip install -i https://pkgs.dev.azure.com/orgname/publicprojectname/_packaging/feedname/pypi/simple/ packagename
To list the content of feed, anonymous users can use a different URL:
https://dev.azure.com/orgname/publicprojectname/_packaging?_a=feed&feed=feedname
Side note: make sure you do not have artifacts-keyring package installed in the venv you use to test anonymous pip access:
pip uninstall -y artifacts-keyring
Otherwise trying to access you feed from pip will trigger the following credential pause:
$ pip install -i https://pkgs.dev.azure.com/orgname/publicprojectname/_packaging/feedname/pypi/simple/ packagename
Looking in indexes: hhttps://pkgs.dev.azure.com/orgname/publicprojectname/_packaging/feedname/pypi/simple/
[Minimal] [CredentialProvider]DeviceFlow: https://pkgs.dev.azure.com/orgname/publicprojectname/_packaging/feedname/pypi/simple/
[Minimal] [CredentialProvider]ATTENTION: User interaction required.
**********************************************************************
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.
**********************************************************************
[Error] [CredentialProvider]Device flow authentication failed. User was presented with device flow, but didn't react within 90 seconds.

Deploying Python Flask on Azure Get error 500

In the following hour's i tried to deploy Python with flask on Microsoft azure platform.
I used New app "flask", assign with their server. deployed by git.
after deployment finished (its showed Unable to find vcvarsall.bat)
Then I set up on options that i am using python 3.4 version and it fixed it up.
After Deployment succeeds I tried to see the site and I got :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I am a beginner in deploying and I search up all over. I really wish somebody could help me find the right answer.
Thank you very much.
Based on my research on this blog which mentioned content below about your issue:
When you see "unable to find vcvarsall.bat", it means you're
installing a package that has an extension module, but only the source
code. "vcvarsall.bat" is part of the compiler in Visual Studio that is
necessary to compile the module.
I think your issue occurred because that during the flask project deployed to azure, pip has problems installing the lxml library.As mentioned in this document, lxml library is written in C which requires a compiler before it's installation.
Unfortunately,a compiler is not available on the machine running the web app in Azure App Service. So, you need to do this compilation locally.
You can follow the steps as below:
Step 1:Use pip wheel command line to generate .whl file of lxml package.In addition,you can directly download generated .whl file here.
Step2:Create the wheelhouse folder under the requments.txt file's sibling directory and put the .whl file in wheelhouse folder.
Step3: Edit your requirements.txt to add the --find-links option at the top.
--find-links wheelhouse
lxml==3.8.0
Step4:Deploy your flask project to azure.
For more details , please refer to the Troubleshooting - Package Installation chapter in the official document and wheel document.
Hope it helps you.

Where to get the CherryPy auth_digest module?

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.

Categories