-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secure web application #3
Comments
You may want to check out Tim Sutton's work on this: https://github.com/timsutton/margarita/tree/flask-basic-auth I'm not yet sure of an architecture for authentication. At some point there'll be documentation on running this as a FastCGI app then authentication, encryption (SSL), etc. could all be handled at that higher level like Apache or Lighttpd. |
Thanks for the suggestion. Tim's solutions will work for now. |
I missed seeing this earlier, but I'd like to know if anyone happens to test loading margarita via a WSGI server instead, and handle the auth there. I'm not experienced with WSGI or web apps in general, so I'll just post my results, and maybe someone with more knowledge than I can comment. I tested adding the app using mod_wsgi on Apache, using the following wsgi.py script: import sys loaded into my VirtualHost using:
The template loaded, but the content area was empty. Checking the JavaScript debugger I saw an error that traced back to jQuery. The VirtualHost is configured to use port 8666.
|
This was exactly the idea above on extending architecture so I'd probably want to have that supported. Not sure about the error, though there is a 500 error so that indicates a problem in the "server side" I'd think. The anonymous function is probably the jQuery ajax call that's done asynchronously. Is there anything in the logs? A Python traceback perhaps? |
Nothing I can see. I've enabled debug-level logging for both Apache's and my vhost, and can see that if I add something to stderr in margarita.py it definitely shows up in the Apache log. I added the sample debugging script to my wsgi.py to trigger a stack trace as suggested at the end of the mod_wsgi Debugging page: http://code.google.com/p/modwsgi/wiki/DebuggingTechniques However when I touch the file to trigger a stack trace I can't get it to dump anything besides the first thread which is doing the traceback itself. I don't know if that's because it's 'missing' the thread (a timing issue) or something else that I'm equally unfamiliar with. Doesn't help if I change the timing interval. I'll paste my VirtualHost config just in case there's something obvious that jumps out to anyone.
|
What does your wsgi.py look like? Is Flask's debugging turned on? |
Wow, I should've thought to look up debug options within Flask itself. It revealed the issue right away:
The function reposadolib uses to determine the directory that a script using reposadolib is run from ( To specify using the reposado code dirrectory as that to be used for the process, I added the 'home' option to the WSGIDaemonProcess Apache directive in my VirtualHost:
And that was enough. I quickly tested the functionality of adding and removing updates from branches and it seems fine. When I get a chance I'll throw together a quick doc and sample wsgi.py and submit a pull request. I can't recommend any 'best practice' as this is very new to me, but I can at least post what I've done in my setup once I've had time to test it a bit more. |
Great! Thanks for tracking that down! I'll look forward to your doc. I'd probably want the WSGI docs to be in the main docs FWIW. But perhaps finally a break-out into a Wiki page will be due. |
using the |
Would you prefer to have this appended to the existing readme, or a On 2012-04-29, at 5:24 PM, Jesse Peterson
|
I'm interested by the WSGI setup. I'm unable to make it working with CentOS. |
I had let this issue die, unfortunately, but Joe Wollard (@buffalo) has just put together a great walkthrough on his blog: http://denisonmac.wordpress.com/2013/02/28/running-margarita-in-apache He's using Ubuntu in the guide. @natewalck put together directions for running MunkiWebAdmin on CentOS based on my notes for Debian, and he found that on CentOS one extra item required was the WSGISocketPrefix Apache directive and manually creating a socket directory for it: https://code.google.com/p/munki/wiki/MunkiWebAdminLinuxSetup Hope that helps someone. |
Wow, fantastic! Thanks for sharing! |
For what its worth Apple's Server.app only accepts WSGI webapps if the file extension is .wsgi Server.app has the benefit of including mod_wsgi as standard. I have not yet tried setting up Margarita in Server.app but have successfully done Crypt Server and MunkiWebAdmin. I have written some general notes on defining a webapp in Server.app here http://jelockwood.blogspot.co.uk/2013/06/running-django-webapps-with-os-x.html I now also define them using virtualenv and this works fine even with Server.app, in fact it usually makes things a little easier as I don't have to alter the paths in the .wsgi file provided by the developer. |
Has anyone got this working with OS X Server? I followed Joe Wollard's basic instructions on getting the .wsgi started and put it together with some of jelockwood's hints. I get the webapp shown in Server.app, but access denied when I try to go to the site. I feel like I'm very close, just missing something... permissions/user:group for the webserver/wsgi possibly. |
Did anything come of this? Would be interested in having a secure login as well as getting it working with server.app |
Same here - I would love to get some basic authentication for margarita - especially for OS X server. |
Ok - I took some ideas from Tim Sutton's fork (https://github.com/timsutton/margarita/tree/flask-basic-auth )and poking around with the basic auth from (http://flask.pocoo.org/snippets/8/) and was able to get basic authentication working within the flask environment for the latest version of margarita. https://github.com/benbasscom/margarita/tree/flask-basic-auth |
When running margarita every visitor of the web application is able to make changes. Please integrate a simple authentication form: http://packages.python.org/Flask-Login/
The text was updated successfully, but these errors were encountered: