From 98217c569ae640de28387a1436dc3457c10dc9cf Mon Sep 17 00:00:00 2001 From: Marco Fargetta Date: Tue, 30 Jun 2015 15:30:00 +0200 Subject: [PATCH] Moved the sso module into a package If the templates are not in a package the setup.py is not able to include the template directory in the installed package --- DiscourseSSO.py | 2 +- DiscourseSSO.wsgi | 2 +- README.rst | 12 ++++++------ src/{ => discourseSSO}/__init__.py | 0 src/{ => discourseSSO}/config.py | 0 src/{ => discourseSSO}/default.py | 0 src/{ => discourseSSO}/sso.py | 2 +- src/{ => discourseSSO}/templates/403.html | 0 src/{ => discourseSSO}/templates/__init__ | 0 tests/test_sso.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) rename src/{ => discourseSSO}/__init__.py (100%) rename src/{ => discourseSSO}/config.py (100%) rename src/{ => discourseSSO}/default.py (100%) rename src/{ => discourseSSO}/sso.py (98%) rename src/{ => discourseSSO}/templates/403.html (100%) rename src/{ => discourseSSO}/templates/__init__ (100%) diff --git a/DiscourseSSO.py b/DiscourseSSO.py index a7ee6cc..0b38013 100644 --- a/DiscourseSSO.py +++ b/DiscourseSSO.py @@ -17,7 +17,7 @@ SSO Application tests """ -import sso +from discourseSSO import sso if __name__ == '__main__': sso.app.run() diff --git a/DiscourseSSO.wsgi b/DiscourseSSO.wsgi index 416211f..eb99116 100644 --- a/DiscourseSSO.wsgi +++ b/DiscourseSSO.wsgi @@ -30,4 +30,4 @@ To run in a virtual environment add the activation code. Es.: """ -from sso import app as application +from discourseSSO.sso import app as application diff --git a/README.rst b/README.rst index 0620a6d..0b95ed3 100644 --- a/README.rst +++ b/README.rst @@ -76,7 +76,7 @@ using saml (for details on mod_shib configuration look at the `official wiki When the server is properly configured download/clone the **DiscourseSSO** package from `GitHub `_ in a directory accessible by apache. Configure mod_wsgi to include the source code of the package and add -the `DiscourseSSO.wsgi` script to the location to use for Discourse. Finally, shibboleth +the ``DiscourseSSO.wsgi`` script to the location to use for Discourse. Finally, shibboleth has to protect the authentication directory so the user has to go to the IdP in order be accepted. The configuration should look like: :: @@ -100,13 +100,13 @@ be accepted. The configuration should look like: :: Finally, both Discourse and DiscourseSSO need to be configured. Enable the sso in Discourse following the `official documentation `_. -The sso url to is the one going to your DiscourseSSO installation plus `sso/login`, so using -the above configuration the url is `https:///DisocurseSSO/sso/login`. +The sso url to is the one going to your DiscourseSSO installation plus ``sso/login``, so using +the above configuration the url is ``https:///DisocurseSSO/sso/login``. The sso_secret is a random string and has to be the same in both services. The configuration -file of DiscourseSSO is `src/config.py` and it require the secret key (`DISCOURSE_SECRET_KEY`), -the url of Discourse (`DISCOURSE_URL`) and the name of the environment variables -where mod_shibb will provide the user information(`DISCOURSE_USER_MAP`). This is a +file of DiscourseSSO is ``src/discoruseSSO/config.py`` and it require the secret key (``DISCOURSE_SECRET_KEY``), +the url of Discourse (``DISCOURSE_URL``) and the name of the environment variables +where mod_shib will provide the user information(``DISCOURSE_USER_MAP``). This is a map where the key is the attribute provided back to Discourse whereas the values are the name of the variables to lookup. The name can be generated combining different values but the other accept only one value. Default are good for a SAML based diff --git a/src/__init__.py b/src/discourseSSO/__init__.py similarity index 100% rename from src/__init__.py rename to src/discourseSSO/__init__.py diff --git a/src/config.py b/src/discourseSSO/config.py similarity index 100% rename from src/config.py rename to src/discourseSSO/config.py diff --git a/src/default.py b/src/discourseSSO/default.py similarity index 100% rename from src/default.py rename to src/discourseSSO/default.py diff --git a/src/sso.py b/src/discourseSSO/sso.py similarity index 98% rename from src/sso.py rename to src/discourseSSO/sso.py index 795d69d..4a7d2ec 100644 --- a/src/sso.py +++ b/src/discourseSSO/sso.py @@ -29,7 +29,7 @@ import urllib app = Flask(__name__) -app.config.from_object('default.Config') +app.config.from_object('discourseSSO.default.Config') app.config.from_pyfile('config.py') app.config.from_envvar('DISCOURSE_SSO_CONFIG', True) diff --git a/src/templates/403.html b/src/discourseSSO/templates/403.html similarity index 100% rename from src/templates/403.html rename to src/discourseSSO/templates/403.html diff --git a/src/templates/__init__ b/src/discourseSSO/templates/__init__ similarity index 100% rename from src/templates/__init__ rename to src/discourseSSO/templates/__init__ diff --git a/tests/test_sso.py b/tests/test_sso.py index ea10b50..a66d0a2 100644 --- a/tests/test_sso.py +++ b/tests/test_sso.py @@ -22,7 +22,7 @@ import pytest from urlparse import urlparse from werkzeug.exceptions import BadRequest, Forbidden -import sso +from discourseSSO import sso app = sso.app