initial packaging files

This commit is contained in:
Serghei Mihai 2014-10-03 12:40:25 +02:00
parent 67092eb4f4
commit 8e7e26ebe4
18 changed files with 29 additions and 242 deletions

20
README
View File

@ -1,20 +0,0 @@
** THIS IS A TEMPLATE PROJECT **
To rename it to your taste:
$ ./adapt.sh
** THIS IS A TEMPLATE PROJECT **
Authentic2 Userinfo
==========================
Install
-------
You just have to install the package in your virtualenv and relaunch, it will
be automatically loaded by authentic2.
Settings
--------
** DESCRIBE CUSTOM SETTINGS HERE **

View File

@ -1,62 +0,0 @@
__version__ = '0.0.1'
class Plugin(object):
def get_before_urls(self):
from . import urls
return urls.urlpatterns
def get_after_urls(self):
return []
def get_apps(self):
return [__name__]
def get_before_middleware(self):
return []
def get_after_middleware(self):
return []
def get_authentication_backends(self):
return []
def get_auth_frontends(self):
return []
def get_idp_backends(self):
return []
def get_admin_modules(self):
from . import dashboard
return dashboard.get_admin_modules()
def service_list(self, request):
'''For IdP plugins this method add links to the user homepage.
It must return a list of authentic2.utils.Service objects, each
object has a name and can have an url and some actions.
Service(name=name[, url=url[, actions=actions]])
Actions are a list of tuples, whose parts are
- first the name of the action,
- the HTTP method for calling the action,
- the URL for calling the action,
- the paramters to pass to this URL as a sequence of key-value tuples.
'''
return []
def logout_list(self, request):
'''For IdP or SP plugins this method add actions to logout from remote
IdP or SP.
It must returns a list of HTML fragments, each fragment is
responsible for calling the view doing the logout. Views are usually
called using <img/> or <iframge/> tags and finally redirect to an
icon indicating success or failure for the logout.
Authentic2 provide two such icons through the following URLs:
- os.path.join(settings.STATIC_URL, 'authentic2/img/ok.png')
- os.path.join(settings.STATIC_URL, 'authentic2/img/ok.png')
'''
return []

View File

@ -1,5 +0,0 @@
from django.contrib import admin
from . import models
# registrer your admin editable models here using admin.register

View File

@ -1,23 +0,0 @@
class AppSettings(object):
__DEFAULTS = {
'ENABLED': True,
}
def __init__(self, prefix):
self.prefix = prefix
def _setting(self, name, dflt):
from django.conf import settings
return getattr(settings, self.prefix+name, dflt)
def __getattr__(self, name):
if name not in self.__DEFAULTS:
raise AttributeError(name)
return self._setting(name, self.__DEFAULTS[name])
# Ugly? Guido recommends this himself ...
# http://mail.python.org/pipermail/python-ideas/2012-May/014969.html
import sys
app_settings = AppSettings('A2_PLUGIN_TEMPLATE_')
app_settings.__name__ = __name__
sys.modules[__name__] = app_settings

View File

@ -1,11 +0,0 @@
from django.utils.translation import ugettext_lazy as _
from admin_tools.dashboard import modules
def get_admin_modules():
'''Show Client model in authentic2 admin'''
model_list = modules.ModelList(_('Authentic2 Userinfo'),
models=('authentic2_userinfo.models.*',))
return (model_list,)

View File

@ -1 +0,0 @@
[{"pk": 2, "model": "authentic2.deleteduser", "fields": {"creation": "2014-09-11T01:11:24.405", "user": 1}}]

View File

@ -1 +0,0 @@
[{"pk": 1, "model": "saml.libertyproviderpolicy", "fields": {"name": "Default", "authn_request_signature_check_hint": 0}}, {"pk": 2, "model": "saml.libertyproviderpolicy", "fields": {"name": "Shibboleth SP", "authn_request_signature_check_hint": 2}}, {"pk": 1, "model": "saml.libertyfederation", "fields": {"creation": "2014-10-03T11:54:25.931", "last_modification": "2014-10-03T12:11:26.686", "name_id_sp_name_qualifier": "", "termination_notified": false, "sp": null, "idp": null, "name_id_qualifier": "", "user": 1, "name_id_content": "_05D1286DA257FB1326C12107576D628B", "name_id_format": ""}}, {"pk": 2, "model": "saml.libertyfederation", "fields": {"creation": "2014-10-03T12:11:10.040", "last_modification": "2014-10-03T12:11:10.040", "name_id_sp_name_qualifier": "", "termination_notified": false, "sp": null, "idp": null, "name_id_qualifier": "", "user": 2, "name_id_content": "_E191B750CC87587E6E2ED2130262C4F2", "name_id_format": ""}}]

File diff suppressed because one or more lines are too long

View File

@ -1,4 +0,0 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
# put your models here

View File

@ -1,32 +0,0 @@
import json
from django.test import TestCase, Client
from django.core.urlresolvers import reverse
class UserInfoTest(TestCase):
fixtures = ('users.json', 'federations.json', 'deleted_users.json')
def setUp(self):
self.client = Client()
def test_existing_user(self):
response = self.client.get(reverse('authentic2-userinfo',
kwargs={'nameid':'_E191B750CC87587E6E2ED2130262C4F2'}))
self.assertEqual(response.status_code, 200)
try:
data = json.loads(response.json)
except:
self.fail('response not a json')
self.assertEqual(data['email'], 'admin@entrouvert.com')
def test_deleted_user(self):
response = self.client.get(reverse('authentic2-userinfo',
kwargs={'nameid':'_05D1286DA257FB1326C12107576D628B'}))
self.assertEqual(response.status_code, 404)
def test_nonexisting_user(self):
response = self.client.get(reverse('authentic2-userinfo',
kwargs={'nameid':'_05D12DFGZVA257FB1326C12107576D628B'}))
self.assertEqual(response.status_code, 404)

View File

@ -1,14 +0,0 @@
from django.conf.urls import patterns, url
from authentic2.decorators import setting_enabled, required
from . import app_settings
from .views import UserFullData
urlpatterns = required(
setting_enabled('ENABLED', settings=app_settings),
patterns('',
url('^userinfo/(?P<nameid>_\w+)$', UserFullData.as_view(),
name='authentic2-userinfo'),
)
)

View File

@ -1,15 +0,0 @@
from django.views.generic import View
from jsonresponse import to_json
from authentic2 import compat
user_model = compat.get_user_model()
class UserFullData(View):
@to_json('api')
def get(self, request, nameid):
user = user_model.objects.get(libertyfederation__name_id_content=nameid, deleteduser__isnull=True)
return {'first_name': user.first_name, 'last_name': user.last_name,
'email': user.email}

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
authentic2-userinfo (0.0.1-1) unstable; urgency=low
* source package automatically created by stdeb 0.8.2
-- Entr'ouvert <info@entrouvert.com> Fri, 03 Oct 2014 12:34:12 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

14
debian/control vendored Normal file
View File

@ -0,0 +1,14 @@
Source: authentic2-userinfo
Maintainer: Entr'ouvert <info@entrouvert.com>
Section: python
Priority: optional
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 9)
Standards-Version: 3.9.1
Package: python-authentic2-userinfo
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, django-jsonresponse
Description: Authentic2 Userinfo.
Returning user's first, last names and email by id

8
debian/rules vendored Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/make -f
# This file was automatically generated by stdeb 0.8.2 at
# Fri, 03 Oct 2014 12:34:12 +0200
%:
dh $@ --with python2

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (quilt)

View File

@ -1,53 +0,0 @@
#!/usr/bin/python
from setuptools import setup, find_packages
import os
def get_version():
import glob
import re
import os
version = None
for d in glob.glob('*'):
module_file = os.path.join(d, '__init__.py')
if not os.path.exists(module_file):
continue
for v in re.findall("""__version__ *= *['"](.*)['"]""",
open(module_file).read()):
assert version is None
version = v
if version:
break
assert version is not None
if os.path.exists('.git'):
import subprocess
p = subprocess.Popen(['git','describe','--dirty','--match=v*'],
stdout=subprocess.PIPE)
result = p.communicate()[0]
assert p.returncode == 0, 'git returned non-zero'
new_version = result.split()[0][1:]
assert new_version.split('-')[0] == version, '__version__ must match the last git annotated tag'
version = new_version.replace('-', '.')
return version
README = file(os.path.join(
os.path.dirname(__file__),
'README')).read()
setup(name='authentic2-userinfo',
version=get_version(),
license='AGPLv3',
description='Authentic2 Userinfo',
long_description=README,
author="Entr'ouvert",
author_email="info@entrouvert.com",
packages=find_packages(os.path.dirname(__file__) or '.'),
install_requires=[
'django-jsonresponse==0.10'
],
entry_points={
'authentic2.plugin': [
'authentic2-userinfo= authentic2_userinfo:Plugin',
],
},
)