Many broken things
This commit is contained in:
3
passbook/oauth_provider/__init__.py
Normal file
3
passbook/oauth_provider/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
"""passbook oauth_provider Header"""
|
||||
__version__ = '0.0.1-alpha'
|
||||
default_app_config = 'passbook.oauth_provider.apps.PassbookOAuthProviderConfig'
|
||||
4
passbook/oauth_provider/admin.py
Normal file
4
passbook/oauth_provider/admin.py
Normal file
@ -0,0 +1,4 @@
|
||||
"""passbook oauth provider Admin"""
|
||||
from passbook.lib.admin import admin_autoregister
|
||||
|
||||
admin_autoregister('passbook_oauth_provider')
|
||||
10
passbook/oauth_provider/apps.py
Normal file
10
passbook/oauth_provider/apps.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""passbook auth oauth provider app config"""
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PassbookOAuthProviderConfig(AppConfig):
|
||||
"""passbook auth oauth provider app config"""
|
||||
|
||||
name = 'passbook.oauth_provider'
|
||||
label = 'passbook_oauth_provider'
|
||||
70
passbook/oauth_provider/locale/de/LC_MESSAGES/django.po
Normal file
70
passbook/oauth_provider/locale/de/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,70 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-16 18:05+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:18
|
||||
msgid "SSO - Authorize External Source"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:29
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You're about to sign into %(remote)s\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:33
|
||||
msgid "Application requires following permissions"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:42
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You are logged in as %(user)s. Not you?\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:45
|
||||
msgid "Logout"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:49
|
||||
msgid "Continue"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:52
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:59
|
||||
#, python-format
|
||||
msgid "Error: %(err)s"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:49
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth) (skipped Authz)"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:62
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth)"
|
||||
msgstr ""
|
||||
69
passbook/oauth_provider/locale/en/LC_MESSAGES/django.po
Normal file
69
passbook/oauth_provider/locale/en/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,69 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-20 10:47+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:18
|
||||
msgid "SSO - Authorize External Source"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:29
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You're about to sign into %(remote)s\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:33
|
||||
msgid "Application requires following permissions"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:42
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You are logged in as %(user)s. Not you?\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:45
|
||||
msgid "Logout"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:49
|
||||
msgid "Continue"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:52
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:59
|
||||
#, python-format
|
||||
msgid "Error: %(err)s"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:49
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth) (skipped Authz)"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:62
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth)"
|
||||
msgstr ""
|
||||
70
passbook/oauth_provider/locale/es/LC_MESSAGES/django.po
Normal file
70
passbook/oauth_provider/locale/es/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,70 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-16 18:05+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:18
|
||||
msgid "SSO - Authorize External Source"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:29
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You're about to sign into %(remote)s\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:33
|
||||
msgid "Application requires following permissions"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:42
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You are logged in as %(user)s. Not you?\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:45
|
||||
msgid "Logout"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:49
|
||||
msgid "Continue"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:52
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:59
|
||||
#, python-format
|
||||
msgid "Error: %(err)s"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:49
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth) (skipped Authz)"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:62
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth)"
|
||||
msgstr ""
|
||||
70
passbook/oauth_provider/locale/fr/LC_MESSAGES/django.po
Normal file
70
passbook/oauth_provider/locale/fr/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,70 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-08-16 18:05+0000\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:18
|
||||
msgid "SSO - Authorize External Source"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:29
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You're about to sign into %(remote)s\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:33
|
||||
msgid "Application requires following permissions"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:42
|
||||
#, python-format
|
||||
msgid ""
|
||||
"\n"
|
||||
" You are logged in as %(user)s. Not you?\n"
|
||||
" "
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:45
|
||||
msgid "Logout"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:49
|
||||
msgid "Continue"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:52
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: templates/oauth2_provider/authorize.html:59
|
||||
#, python-format
|
||||
msgid "Error: %(err)s"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:49
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth) (skipped Authz)"
|
||||
msgstr ""
|
||||
|
||||
#: views/oauth2.py:62
|
||||
#, python-format
|
||||
msgid "You authenticated %s (via OAuth)"
|
||||
msgstr ""
|
||||
29
passbook/oauth_provider/migrations/0001_initial.py
Normal file
29
passbook/oauth_provider/migrations/0001_initial.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Generated by Django 2.1.3 on 2018-11-14 18:35
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.OAUTH2_PROVIDER_APPLICATION_MODEL),
|
||||
('passbook_core', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='OAuth2Application',
|
||||
fields=[
|
||||
('application_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='passbook_core.Application')),
|
||||
('oauth2', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.OAUTH2_PROVIDER_APPLICATION_MODEL)),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('passbook_core.application',),
|
||||
),
|
||||
]
|
||||
0
passbook/oauth_provider/migrations/__init__.py
Normal file
0
passbook/oauth_provider/migrations/__init__.py
Normal file
12
passbook/oauth_provider/models.py
Normal file
12
passbook/oauth_provider/models.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""Oauth2 provider product extension"""
|
||||
|
||||
from django.db import models
|
||||
from oauth2_provider.models import Application as _OAuth2Application
|
||||
|
||||
from passbook.core.models import Application
|
||||
|
||||
|
||||
class OAuth2Application(Application):
|
||||
"""Associate an OAuth2 Application with a Product"""
|
||||
|
||||
oauth2 = models.ForeignKey(_OAuth2Application, on_delete=models.CASCADE)
|
||||
2
passbook/oauth_provider/requirements.txt
Normal file
2
passbook/oauth_provider/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
django-oauth-toolkit
|
||||
django-cors-middleware
|
||||
16
passbook/oauth_provider/settings.py
Normal file
16
passbook/oauth_provider/settings.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""passbook OAuth_Provider"""
|
||||
|
||||
CORS_ORIGIN_ALLOW_ALL = True
|
||||
REQUEST_APPROVAL_PROMPT = 'auto'
|
||||
|
||||
MIDDLEWARE = [
|
||||
'oauth2_provider.middleware.OAuth2TokenMiddleware',
|
||||
'corsheaders.middleware.CorsMiddleware',
|
||||
]
|
||||
INSTALLED_APPS = [
|
||||
'oauth2_provider',
|
||||
'corsheaders',
|
||||
]
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'oauth2_provider.backends.OAuth2Backend',
|
||||
]
|
||||
12
passbook/oauth_provider/urls.py
Normal file
12
passbook/oauth_provider/urls.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""passbook oauth_provider urls"""
|
||||
|
||||
from django.urls import include, path
|
||||
|
||||
from passbook.oauth_provider.views import oauth2
|
||||
|
||||
urlpatterns = [
|
||||
# Custom OAuth 2 Authorize View
|
||||
# path('authorize/', oauth2.PassbookAuthorizationView.as_view(), name="oauth2-authorize"),
|
||||
# OAuth API
|
||||
path('oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
|
||||
]
|
||||
0
passbook/oauth_provider/views/__init__.py
Normal file
0
passbook/oauth_provider/views/__init__.py
Normal file
58
passbook/oauth_provider/views/oauth2.py
Normal file
58
passbook/oauth_provider/views/oauth2.py
Normal file
@ -0,0 +1,58 @@
|
||||
"""passbook OAuth2 Views"""
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
from django.contrib import messages
|
||||
from django.http import Http404, HttpResponseRedirect
|
||||
from django.utils.translation import ugettext as _
|
||||
from oauth2_provider.models import get_application_model
|
||||
from oauth2_provider.views.base import AuthorizationView
|
||||
|
||||
# from passbook.core.models import Event, UserAcquirableRelationship
|
||||
|
||||
LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
class PassbookAuthorizationView(AuthorizationView):
|
||||
"""Custom OAuth2 Authorization View which checks for invite_only products"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
"""Check if request.user has a relationship with product"""
|
||||
full_res = super().get(request, *args, **kwargs)
|
||||
# If application cannot be found, oauth2_data is {}
|
||||
if self.oauth2_data == {}:
|
||||
return full_res
|
||||
# self.oauth2_data['application'] should be set, if not an error occured
|
||||
# if 'application' in self.oauth2_data:
|
||||
# app = self.oauth2_data['application']
|
||||
# if app.productextensionoauth2_set.exists() and \
|
||||
# app.productextensionoauth2_set.first().product_set.exists():
|
||||
# # Only check if there is a connection from OAuth2 Application to product
|
||||
# product = app.productextensionoauth2_set.first().product_set.first()
|
||||
# relationship = UserAcquirableRelationship.objects.filter(user=request.user,
|
||||
# model=product)
|
||||
# # Product is invite_only = True and no relation with user exists
|
||||
# if product.invite_only and not relationship.exists():
|
||||
# LOGGER.warning("User '%s' has no invitation to '%s'", request.user, product)
|
||||
# messages.error(request, "You have no access to '%s'" % product.name)
|
||||
# raise Http404
|
||||
# if isinstance(full_res, HttpResponseRedirect):
|
||||
# # Application has skip authorization on
|
||||
# Event.create(
|
||||
# user=request.user,
|
||||
# message=_('You authenticated %s (via OAuth) (skipped Authz)' % app.name),
|
||||
# request=request,
|
||||
# current=False,
|
||||
# hidden=True)
|
||||
return full_res
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Add event on confirmation"""
|
||||
app = get_application_model().objects.get(client_id=request.GET["client_id"])
|
||||
# Event.create(
|
||||
# user=request.user,
|
||||
# message=_('You authenticated %s (via OAuth)' % app.name),
|
||||
# request=request,
|
||||
# current=False,
|
||||
# hidden=True)
|
||||
return super().post(request, *args, **kwargs)
|
||||
Reference in New Issue
Block a user