Begin integration of django rest framework
This commit is contained in:
parent
536e639cd3
commit
41c49800ee
4 changed files with 101 additions and 37 deletions
101
README.md
101
README.md
|
@ -1,57 +1,50 @@
|
||||||
# ungleich-otp
|
# ungleich-otp
|
||||||
|
|
||||||
The ungleich OTP service that allows you access to the ungleich micro
|
ungleich-otp is a full blown authentication and authorisation service
|
||||||
service infrastructure.
|
made for micro services.
|
||||||
|
|
||||||
We are using
|
The basic idea is that every micro service has a (long term) seed and
|
||||||
|
creates time based tokens (TOTP, RFCXXXX).
|
||||||
|
|
||||||
- nameko for internal communication
|
## Setup instructions ##
|
||||||
- django for the DB + admin interface
|
|
||||||
|
|
||||||
## Status
|
This is a standard django project and thus can be easily setup using
|
||||||
|
|
||||||
In development, pre production.
|
|
||||||
|
|
||||||
## Usage: WEB
|
|
||||||
|
|
||||||
- No user interface (UI) supported (?)
|
|
||||||
-> idea is to keep flow logic in ungleich-dynamicweb
|
|
||||||
|
|
||||||
## Usage: BUS
|
|
||||||
|
|
||||||
### RPC: verify(appuuid, token, appuuidtoverify, tokentoverify)
|
|
||||||
|
|
||||||
Verify whether the requesting app is authenticated. This is only
|
|
||||||
allowed to be used for trusted appuuids.
|
|
||||||
|
|
||||||
Returns a JSON object:
|
|
||||||
|
|
||||||
Either
|
|
||||||
```
|
|
||||||
{
|
|
||||||
status: "OK"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
OR
|
|
||||||
|
|
||||||
```
|
```
|
||||||
{
|
pip install -r requirements.txt
|
||||||
status: "FAIL"
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
To bootstrap the application, you need your very first trusted seed to
|
||||||
|
access the application. You can generate it using
|
||||||
|
|
||||||
|
```
|
||||||
|
to be filled in
|
||||||
|
```
|
||||||
|
|
||||||
## Usage: REST
|
After that, you can run the application using
|
||||||
|
|
||||||
|
```
|
||||||
|
python manage.py runserver
|
||||||
|
```
|
||||||
|
|
||||||
|
The usual instructions on how to setup an https proxy should be followed.
|
||||||
|
|
||||||
|
## Realms ##
|
||||||
|
|
||||||
|
Access is granting/denied based on realms. There are two reserved
|
||||||
|
realms, all other realms can be used by the users:
|
||||||
|
|
||||||
|
* ungleich-admin: realm??
|
||||||
|
|
||||||
|
## Status ##
|
||||||
|
|
||||||
|
## Usage: REST ##
|
||||||
|
|
||||||
- Use an existing token to connect to the service
|
- Use an existing token to connect to the service
|
||||||
- All REST based messages: JSON
|
- All REST based messages: JSON
|
||||||
|
|
||||||
### POST: /verify
|
### POST: /verify
|
||||||
|
|
||||||
Not sure if this one will be publicly available.
|
|
||||||
|
|
||||||
Request JSON object:
|
Request JSON object:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -81,6 +74,40 @@ OR
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### POST /register
|
||||||
|
|
||||||
|
Register a new seed. Returns an app ID.
|
||||||
|
|
||||||
|
Request JSON object:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
version: "1",
|
||||||
|
appuuid: "your-app-uuid",
|
||||||
|
token: "current time based token",
|
||||||
|
username: "user this app belongs to",
|
||||||
|
appname: "name of your web app"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Response JSON object:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
status: "OK",
|
||||||
|
appuuid: "UUID of your app",
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
OR
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
status: "FAIL",
|
||||||
|
error: "Reason for failure"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### POST /app/register
|
### POST /app/register
|
||||||
|
|
||||||
Register a new app. Returns an app ID.
|
Register a new app. Returns an app ID.
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
pyotp>=2.2.6
|
pyotp>=2.2.6
|
||||||
django>=2.1.2
|
django>=2.1.2
|
||||||
|
djangorestframework
|
||||||
|
|
||||||
|
# Recommended
|
||||||
|
markdown
|
||||||
|
django-filter
|
||||||
|
|
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'rest_framework',
|
||||||
'otpauth'
|
'otpauth'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,38 @@ Including another URLconf
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
# from django.conf.urls import url, include
|
||||||
|
|
||||||
|
|
||||||
|
# urlpatterns = [
|
||||||
|
|
||||||
|
# url(r'^api-auth/', include('rest_framework.urls'))
|
||||||
|
# ]
|
||||||
|
|
||||||
|
|
||||||
|
from django.conf.urls import url, include
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from rest_framework import routers, serializers, viewsets
|
||||||
|
|
||||||
|
# Serializers define the API representation.
|
||||||
|
class UserSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = User
|
||||||
|
fields = ('url', 'username', 'email', 'is_staff')
|
||||||
|
|
||||||
|
# ViewSets define the view behavior.
|
||||||
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
queryset = User.objects.all()
|
||||||
|
serializer_class = UserSerializer
|
||||||
|
|
||||||
|
# Routers provide an easy way of automatically determining the URL conf.
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
router.register(r'users', UserViewSet)
|
||||||
|
|
||||||
|
# Wire up our API using automatic URL routing.
|
||||||
|
# Additionally, we include login URLs for the browsable API.
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
|
url(r'^', include(router.urls)),
|
||||||
|
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework'))
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue