Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9 implement user authentication backend #21

Merged
merged 7 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ frontend/.vscode/

api/logs.sqlite3
__pycache__

.idea

api/.env
3 changes: 3 additions & 0 deletions api/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ name = "pypi"
[packages]
djangorestframework = "==3.14.0"
django = "==5.0.2"
webauthn = "*"
django-cors-headers = "*"
django-environ = "*"

[dev-packages]

Expand Down
189 changes: 188 additions & 1 deletion api/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion api/neurona/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

ALLOWED_HOSTS = []

# Application definition
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
"http://127.0.0.1:3000",
]

# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
Expand All @@ -36,11 +41,13 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
"corsheaders",
"neuronaApp",
"neuronaLogs"
]

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
Expand Down Expand Up @@ -124,3 +131,12 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

# Environment variables
# source : https://alicecampkin.medium.com/how-to-set-up-environment-variables-in-django-f3c4db78c55f
import environ
env = environ.Env()
environ.Env.read_env()

PASSKEY_RP_ID = env("PASSKEY_RP_ID")
PASSKEY_ORIGIN = env("PASSKEY_ORIGIN")
3 changes: 2 additions & 1 deletion api/neurona/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path("admin/", admin.site.urls),
path("api/", include("neuronaApp.urls"))
]
18 changes: 18 additions & 0 deletions api/neuronaApp/migrations/0005_alter_challenges_challenge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-03-08 08:45

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('neuronaApp', '0004_commentsvotes'),
]

operations = [
migrations.AlterField(
model_name='challenges',
name='challenge',
field=models.BinaryField(),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.2 on 2024-03-10 18:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('neuronaApp', '0005_alter_challenges_challenge'),
]

operations = [
migrations.AlterField(
model_name='publickeys',
name='credential_id',
field=models.BinaryField(),
),
migrations.AlterField(
model_name='publickeys',
name='key',
field=models.BinaryField(),
),
]
18 changes: 18 additions & 0 deletions api/neuronaApp/migrations/0007_alter_user_display_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-03-10 18:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('neuronaApp', '0006_alter_publickeys_credential_id_alter_publickeys_key'),
]

operations = [
migrations.AlterField(
model_name='user',
name='display_name',
field=models.CharField(blank=True, max_length=100),
),
]
17 changes: 17 additions & 0 deletions api/neuronaApp/migrations/0008_remove_user_passkey_user_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 5.0.2 on 2024-03-10 18:56

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('neuronaApp', '0007_alter_user_display_name'),
]

operations = [
migrations.RemoveField(
model_name='user',
name='passkey_user_id',
),
]
18 changes: 18 additions & 0 deletions api/neuronaApp/migrations/0009_publickeys_sign_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-03-14 17:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('neuronaApp', '0008_remove_user_passkey_user_id'),
]

operations = [
migrations.AddField(
model_name='publickeys',
name='sign_count',
field=models.IntegerField(default=0),
),
]
Loading