Sharepoint api functions execute via python module through proxied communication - python

Has anyone tried to execute a sharepoint function via python module through a proxy? I’ve tried to use shareplum and other python modules to execute the sharepoint calls, but run into an issue with the tls version not being valid or ssl error. I’ve tried setting the tls version, but still get an invalid version for the ssl or the tls version depending. I know I’m able to access the proxy, but fail to access the sharepoint site with a bad authentication.
I can access other sites via request, but I know that I need shareplum or something similar to execute the sharepoint site functions. If not going through a proxy, then I have no issue. However, my company recently deployed a proxy and now my script is no longer working. The code to use shareplum is similar to the code provide by the git project. However, the git project assumes straightforward communication to the web server with https or http
I’ve tried changing the tls version to default 1.1 and 1.2, but neither work. I’ve also tried setting the protocol to http verses https and tried to first pass the proxy server, but no success. I tried using proxy manager using the proxy, then using the created session to access the sharepoint site, but that also fails. Using the proxy manager caused a bad authentication with the sharepoint site.

Related

How can we use Django LiveServerTestCase with Selenium to test https urls

Our end-to-end tests use Django's LiveServerTestCase with Selenium. So far we have only been able to run these on insecure urls. However, some of the libraries that we use (Square) require a page to be on https even in sandbox mode.
When attempting to connect to a secure url, Selenium/Chrome Webdriver simply shows the standard SSL not supported error:
This site can’t provide a secure connection chezpierre.localtest.me sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
Does anyone know if it is possible to enable https on a LiveServerTestCase?
If not, does anyone have a working workaround for this? I'm trying to avoid running a separate https proxy on our build box, but it seems like it might be the only way.
After quick research I found out that this is impossible in Django suggested by this old code ticket https://code.djangoproject.com/ticket/25328
I also found out that you could setup a tunnel to bypass this issue. However this applies to django development server. This is kind of tricky so I am leaving links to posts as the method is rather long:
https://www.ianlewis.org/en/testing-https-djangos-development-server
or
How can I test https connections with Django as easily as I can non-https connections using 'runserver'?
ALTERNATIVE - In my opinion better
There is also a simpler way using an external package. It gives you out of the box a https capable django development server. The project is active and maintained
https://github.com/teddziuba/django-sslserver

How to set up a connection with Kerberos in Python application?

I have task to create SSO (single sign-on) authorization in Python backend application with the help of Kerberos and Active Directory.
In other words, frontend application make AJAX GET request of the specific URL of the backend application. That backend application must return information about employee in JSON format.
What I have done so far:
1) SPN name for the backend application was created in Active Directory.
2) krb5.keytab file for the backend application was created.
3) Active Directory and Kerberos server located on remote Windows server.
4) Backend application would be in Linux Docker container.
5) I install Kerberos client to Docker container.
6) Kerberos Realm: SERVICE.LOCAL.
7) Hostname for the KDC Server: CS001, CS002, CS003.
Have you ever seen any implementations of the above process in Python? I will be grateful for any help.
You have 2 ways to handle this:
Handle it directly in Python
Handle it in a proxy such as apache or nginx
Pure Python Solution
If you don't have a proxy or just want to handle it in python anyway, I recommend using the python-gssapi library. Here's a code sample. There are other Python bindings but from my reading, this one seems to be the most complete.
Note, if you handle it this way, your python server will probably need to be able to respect the keep-alive header (i.e. re-use the same connection for multiple requests). This isn't strictly part of the SPENGO protocol, but most browsers seem to require that the server implements it.
Proxy Solution
If you're using apache, there's a mod_auth_kerb module you can use which is well documented. There's also a mod_auth_gssapi which provides similar functionality.
For nginx, there's a similar module available.
With any of these proxy solutions, the idea is that the proxy handles Kerberos auth, and sets the REMOTE_USER env variable for your python app. So your python app needs to be able to accept this variable as an authenticated user. Django has middleware specifically for that purpose - I'm not sure about Flask (I mention these 2 frameworks because they're in your question's tags).

Python Requests: Connect to Sharepoint online with 2-factor auth enabled

I would like to create a Python script to retrieve lists from Sharepoint Online and potentially update them. I can do all of this from the browser just fine. However, I'm having a hard time connecting to Sharepoint using the Requests module. When I navigate to https://mysharepoint.sharepoint.com, I get redirected to the https://login.microsoftonline.com to log in through my account. The login mechanism also requires two-factor authentication.
I'm not sure whether there's a way I could log in using Python at all at this point. Most of the packages I've tried have not been able to authenticate my user.

Is there any thing needed for https python web page

I been using python to create an web app and it has been doing well so far. Now I would like to encrypt the transmission of the data between client and server using https. The communication is generally just post form and web pages, no money transactions are involve. Is there anything I need to change to the python code except setting the server up with certificate and configurate it to use https? I see a lot of information regarding ssl for python and I not sure if I need those modules and python setup to make https work.
Thanks
Typically, the ssl part for Python web app is managed by some frontend web server like nginx, apache or so.
This does not require any modification of your code (assuming, you are not expecting user to authenticate by ssl certificate on client side, what is quite exotic, but possible scenario).
If you want to run pure Python solution, I would recommend using cherrypy, which is able providing rather reliable and performant web server part (it will be very likely slower then served behind nginx or apache).

Can you run ssl with bottle + AD Authenticate?

I have been looking at multiple sources and can't seem to get a good answer. I am trying to deploy a very simple app that displays information from a mongodb, accepts post data for input, uses SSL, and AD for Authentication.
I am using bottle with python 2.7, mongodb, on a windows 64-bit platform. I can switch to CentOS if that is completely necessary.
So far, none of the very few tutorials out there seem to work on my current configuration. Is what I'm asking for possible? Should I switch to a different framework?
tldr:
Can you run a bottle application with SSL and AD integration?
If not, what python framework would be nearly as easy and still have this functionality.
edit: I found this for flask. Could it work with bottle? Also, can it be done on windows?
There are definitely ways to accomplish your goal of having bottle use SSL + AD on windows.
SSL with bottle:
https://github.com/nickbabcock/bottle-ssl
http://dgtool.blogspot.com/2011/12/ssl-encryption-in-python-bottle.html
bottle on cherrypy server + ssl
python with AD (as well as information on windows specifically):
Authenticating against active directory using python + ldap
https://gist.github.com/ibeex/1288159
If you wanted to use session management for authentication you could pair the AD with bottle middleware such as beaker: bottle hooks with beaker session middleware and checking logins
Bottle itself does not have built in abilities to deal with SSL that I know of like flask. But the last SSL link above shows similar simple useability.

Categories