init oidc

This commit is contained in:
sinavir 2023-02-13 15:26:52 +01:00
parent aaae8a23da
commit 37cc9c1bb8
4 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,2 @@
OIDC_RP_CLIENT_ID = ""
OIDC_RP_CLIENT_SECRET = ""

View file

@ -12,6 +12,20 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
from pathlib import Path from pathlib import Path
from . import secret
# import secrets
OIDC_RP_CLIENT_ID = secret.OIDC_RP_CLIENT_ID
OIDC_RP_CLIENT_SECRET = secret.OIDC_RP_CLIENT_SECRET
# Mozilla OIDC
OIDC_OP_AUTHORIZATION_ENDPOINT = "<URL of the OIDC OP authorization endpoint>"
OIDC_OP_TOKEN_ENDPOINT = "<URL of the OIDC OP token endpoint>"
OIDC_OP_USER_ENDPOINT = "<URL of the OIDC OP userinfo endpoint>"
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
@ -37,6 +51,7 @@ INSTALLED_APPS = [
"django.contrib.sessions", "django.contrib.sessions",
"django.contrib.messages", "django.contrib.messages",
"django.contrib.staticfiles", "django.contrib.staticfiles",
"mozilla_django_oidc",
"rest_framework", "rest_framework",
# "django_extensions", # "django_extensions",
"budget", "budget",
@ -116,6 +131,8 @@ AUTH_PASSWORD_VALIDATORS = [
}, },
] ]
# Auth backends
AUTHENTICATION_BACKENDS = ("mozilla_django_oidc.auth.OIDCAuthenticationBackend",)
# Internationalization # Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/ # https://docs.djangoproject.com/en/3.2/topics/i18n/

23
mozilla-django-oidc.nix Normal file
View file

@ -0,0 +1,23 @@
{ lib, buildPythonPackage, fetchFromGitHub, django, josepy, requests, cryptography }:
buildPythonPackage {
pname = "mozilla-django-oidc";
version = "3.0.0";
src = fetchFromGitHub {
owner = "mozilla";
repo = "mozilla-django-oidc";
rev = "71e4af8283a10aa51234de705d34cd298e927f97";
hash = "sha256-bAuL6JDLU7oigEgdIrGHhO8ZnD0g0ulQ1IoY79HDnNo=";
};
propagatedBuildInputs = [
django
josepy
requests
cryptography
];
doCheck = false;
meta = with lib; {
description = "A lightweight authentication and access management library for integration with OpenID Connect enabled authentication services.";
homepage = "https://mozilla-django-oidc.readthedocs.io";
license = licenses.mpl20;
};
}

View file

@ -2,7 +2,8 @@
let let
python = pkgs.python310.override { python = pkgs.python310.override {
packageOverrides = self: super: { packageOverrides = self: super: {
django = super.django_4; django = self.django_4;
mozilla-django-oidc = self.callPackage ./mozilla-django-oidc.nix {};
}; };
}; };
in in
@ -15,6 +16,7 @@ pkgs.mkShell {
ps.djangorestframework ps.djangorestframework
# (ps.django-extensions.override { inherit django; }) # (ps.django-extensions.override { inherit django; })
# ps.django-compressor # ps.django-compressor
ps.mozilla-django-oidc
])) ]))
]; ];
} }