You've already forked bthlabs-jsonrpc
v1.1.0b1
This commit is contained in:
@@ -1,12 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
ASGI config for django_jsonrpc_django_example project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/
|
||||
"""
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
from django.contrib.auth.middleware import RemoteUserMiddleware
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pathlib import Path
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
# type: ignore
|
||||
import pathlib
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
BASE_DIR = pathlib.Path(__file__).resolve().parent.parent.parent
|
||||
|
||||
SECRET_KEY = None
|
||||
DEBUG = False
|
||||
@@ -71,6 +73,10 @@ STATIC_URL = 'static/'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
AUTHENTICATION_BACKENDS = [
|
||||
'django.contrib.auth.backends.ModelBackend',
|
||||
]
|
||||
|
||||
JSONRPC_METHOD_MODULES = [
|
||||
'bthlabs_jsonrpc_django_example.things.rpc_methods',
|
||||
]
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# django-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from django.contrib import admin
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
from bthlabs_jsonrpc_django_example.things import models
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# django-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# django-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# django-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
from bthlabs_jsonrpc_core import JSONRPCAccessDeniedError, register_method
|
||||
|
||||
from bthlabs_jsonrpc_django_example.things.models import Thing
|
||||
|
||||
@@ -1,14 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
from bthlabs_jsonrpc_django import JSONRPCView, is_authenticated, is_staff
|
||||
from bthlabs_jsonrpc_core.ext.jwt import ALGORITHMS, HMACKey, JWTCodec, KeyPair
|
||||
|
||||
|
||||
class JWTRPCView(JSONRPCView):
|
||||
codec = JWTCodec
|
||||
|
||||
def get_codec(self, request):
|
||||
return JWTCodec(
|
||||
KeyPair(
|
||||
decode_key=HMACKey('thisisntasecrurekeydontuseitpls=', ALGORITHMS.HS256),
|
||||
encode_key=HMACKey('thisisntasecrurekeydontuseitpls=', ALGORITHMS.HS256),
|
||||
),
|
||||
issuer='bthlabs_jsonrpc_django_example',
|
||||
ttl=datetime.timedelta(seconds=3600),
|
||||
)
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path(
|
||||
'rpc/admin',
|
||||
JSONRPCView.as_view(
|
||||
JWTRPCView.as_view(
|
||||
auth_checks=[is_authenticated, is_staff],
|
||||
namespace='admin',
|
||||
),
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
WSGI config for django_jsonrpc_django_example project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/
|
||||
"""
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
# -*- coding: utf-8 -*-
|
||||
# bthlabs-jsonrpc-django | (c) 2022-present Tomek Wójcik | MIT License
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault(
|
||||
'DJANGO_SETTINGS_MODULE',
|
||||
'bthlabs_jsonrpc_django_example.settings.local',
|
||||
)
|
||||
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
@@ -20,6 +23,7 @@ def main():
|
||||
"forget to activate a virtual environment?"
|
||||
),
|
||||
) from exc
|
||||
|
||||
execute_from_command_line(sys.argv)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user