From 45c5fe7a86754052c36b79423905e68271f7394e Mon Sep 17 00:00:00 2001 From: juanifioren Date: Thu, 19 Mar 2015 17:10:00 -0300 Subject: [PATCH] Add example app. --- example_app/.gitignore | 1 + example_app/README.md | 23 +++++++++ example_app/manage.py | 10 ++++ example_app/provider_app/__init__.py | 0 example_app/provider_app/settings.py | 76 ++++++++++++++++++++++++++++ example_app/provider_app/urls.py | 8 +++ example_app/provider_app/wsgi.py | 5 ++ example_app/requirements.txt | 2 + 8 files changed, 125 insertions(+) create mode 100644 example_app/.gitignore create mode 100644 example_app/README.md create mode 100755 example_app/manage.py create mode 100644 example_app/provider_app/__init__.py create mode 100644 example_app/provider_app/settings.py create mode 100644 example_app/provider_app/urls.py create mode 100644 example_app/provider_app/wsgi.py create mode 100644 example_app/requirements.txt diff --git a/example_app/.gitignore b/example_app/.gitignore new file mode 100644 index 0000000..6e9bc0c --- /dev/null +++ b/example_app/.gitignore @@ -0,0 +1 @@ +*.sqlite3 \ No newline at end of file diff --git a/example_app/README.md b/example_app/README.md new file mode 100644 index 0000000..34dc26d --- /dev/null +++ b/example_app/README.md @@ -0,0 +1,23 @@ +# Example Django App + +This is just a simple Django app with all the necessary things to work with `django-oidc-provider` package. + +## Setup & Running + +Setup project environment with [virtualenv](https://virtualenv.pypa.io) and [pip](https://pip.pypa.io). + +```bash +$ virtualenv project_env +$ source project_env/bin/activate +$ git clone https://github.com/juanifioren/django-oidc-provider.git +$ cd django-oidc-provider/example_app +$ pip install -r requirements.txt +``` + +Run your provider. + +```bash +$ python manage.py makemigrations +$ python manage.py migrate +$ python manage.py runserver +``` \ No newline at end of file diff --git a/example_app/manage.py b/example_app/manage.py new file mode 100755 index 0000000..ff8c2cf --- /dev/null +++ b/example_app/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "provider_app.settings") + + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/example_app/provider_app/__init__.py b/example_app/provider_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/example_app/provider_app/settings.py b/example_app/provider_app/settings.py new file mode 100644 index 0000000..ea08d5f --- /dev/null +++ b/example_app/provider_app/settings.py @@ -0,0 +1,76 @@ +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +import os +BASE_DIR = os.path.dirname(os.path.dirname(__file__)) + + +# Quick-start development settings - unsuitable for production + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'waw%j=vza!vc1^eyosw%#_!gg96%zb7sp*+!owkutue4i(sm91' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +TEMPLATE_DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = ( + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + + 'oidc_provider', +) + +MIDDLEWARE_CLASSES = ( + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +) + +ROOT_URLCONF = 'provider_app.urls' + +WSGI_APPLICATION = 'provider_app.wsgi.application' + + +# Database + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + +# Internationalization + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) + +STATIC_URL = '/static/' + + +# OIDC Provider settings. + +SITE_URL = 'http://localhost:8000' \ No newline at end of file diff --git a/example_app/provider_app/urls.py b/example_app/provider_app/urls.py new file mode 100644 index 0000000..747fd50 --- /dev/null +++ b/example_app/provider_app/urls.py @@ -0,0 +1,8 @@ +from django.conf.urls import patterns, include, url +from django.contrib import admin + +urlpatterns = patterns('', + url(r'^openid/', include('oidc_provider.urls', namespace='oidc_provider')), + + url(r'^admin/', include(admin.site.urls)), +) diff --git a/example_app/provider_app/wsgi.py b/example_app/provider_app/wsgi.py new file mode 100644 index 0000000..cfd9ffa --- /dev/null +++ b/example_app/provider_app/wsgi.py @@ -0,0 +1,5 @@ +import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "provider_app.settings") + +from django.core.wsgi import get_wsgi_application +application = get_wsgi_application() diff --git a/example_app/requirements.txt b/example_app/requirements.txt new file mode 100644 index 0000000..3397367 --- /dev/null +++ b/example_app/requirements.txt @@ -0,0 +1,2 @@ +django==1.7.7 +django-oidc-provider==0.0.1