Compare commits
1 commit
main
...
profile-ge
Author | SHA1 | Date | |
---|---|---|---|
639ea92368 |
6 changed files with 101 additions and 1 deletions
|
@ -17,12 +17,21 @@ Including another URLconf
|
|||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.urls import include, path
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [
|
||||
path("", TemplateView.as_view(template_name="home.html"), name="index"),
|
||||
path("login", TemplateView.as_view(template_name="login.html"), name="login"),
|
||||
path(
|
||||
"profiles.html",
|
||||
login_required(TemplateView.as_view(template_name="profiles.html")),
|
||||
name="profiles",
|
||||
),
|
||||
path("profiles/ios.xml", views.profile_ios, name="profiles-ios"),
|
||||
path("", include("dgsi.urls")),
|
||||
path("accounts/", include("allauth.urls")),
|
||||
]
|
||||
|
|
10
src/app/utils.py
Normal file
10
src/app/utils.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
import json
|
||||
|
||||
import kanidm
|
||||
|
||||
|
||||
async def get_radius_credential(username):
|
||||
config = kanidm.KanidmClientConfig(uri="https://sso.dgnum.eu")
|
||||
client = kanidm.KanidmClient(config=config)
|
||||
token = await client.get_radius_token(username)
|
||||
return json.loads(token.content)["secret"]
|
18
src/app/views.py
Normal file
18
src/app/views.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
from asgiref.sync import async_to_sync, sync_to_async
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
|
||||
from . import utils
|
||||
|
||||
|
||||
@sync_to_async
|
||||
@login_required(login_url="/login/")
|
||||
@async_to_sync
|
||||
async def profile_ios(request):
|
||||
radius_credential = await utils.get_radius_credential(request.user.username)
|
||||
return render(
|
||||
request,
|
||||
"iosprofile.xml",
|
||||
{"radius_credential": radius_credential},
|
||||
content_type="text/xml",
|
||||
)
|
|
@ -1,3 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
{% block content %}
|
||||
<ul>
|
||||
<li><a href="profiles.html">Profils WiFi</a></li>
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
51
src/shared/templates/iosprofile.xml
Normal file
51
src/shared/templates/iosprofile.xml
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PayloadContent</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>AutoJoin</key>
|
||||
<true/>
|
||||
<key>CaptiveBypass</key>
|
||||
<false/>
|
||||
<key>EncryptionType</key>
|
||||
<string>WPA2</string>
|
||||
<key>HIDDEN_NETWORK</key>
|
||||
<false/>
|
||||
<key>IsHotspot</key>
|
||||
<false/>
|
||||
<key>Password</key>
|
||||
<string>{{ radius_credential }}</string>
|
||||
<key>PayloadDescription</key>
|
||||
<string>Configures Wi-Fi settings</string>
|
||||
<key>PayloadDisplayName</key>
|
||||
<string>DGNum WiFi</string>
|
||||
<key>PayloadIdentifier</key>
|
||||
<string>com.apple.wifi.managed.5A2AE473-F6B7-4D60-9778-B25D26317C41</string>
|
||||
<key>PayloadType</key>
|
||||
<string>com.apple.wifi.managed</string>
|
||||
<key>PayloadUUID</key>
|
||||
<string>5A2AE473-F6B7-4D60-9778-B25D26317C41</string>
|
||||
<key>PayloadVersion</key>
|
||||
<integer>1</integer>
|
||||
<key>ProxyType</key>
|
||||
<string>None</string>
|
||||
<key>SSID_STR</key>
|
||||
<string>DGNum</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>PayloadDisplayName</key>
|
||||
<string>DGNum WiFi</string>
|
||||
<key>PayloadIdentifier</key>
|
||||
<string>WiFi-PSK-Sample.D5B78A3C-CDA8-471F-984C-06F977EF870C</string>
|
||||
<key>PayloadRemovalDisallowed</key>
|
||||
<false/>
|
||||
<key>PayloadType</key>
|
||||
<string>Configuration</string>
|
||||
<key>PayloadUUID</key>
|
||||
<string>444C9683-221C-49AF-997D-2B6B84710DAA</string>
|
||||
<key>PayloadVersion</key>
|
||||
<integer>1</integer>
|
||||
</dict>
|
||||
</plist>
|
8
src/shared/templates/profiles.html
Normal file
8
src/shared/templates/profiles.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="buttons">
|
||||
<a class="button is-link is-soft">iOS</a>
|
||||
<a class="button is-danger is-soft">Android</a>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue