From c4f666c0270de40984a9a7b1c228a2c2f2266e77 Mon Sep 17 00:00:00 2001 From: TuxCoder Date: Fri, 4 Feb 2022 21:47:01 +0100 Subject: [PATCH] add nix packaging files --- default.nix | 118 +++++++++++++++++++++ lenticular_cloud/app.py | 4 +- lenticular_cloud/views/api.py | 1 - shell.nix | 12 +++ templates/frontend/client_cert_new.html.j2 | 4 - 5 files changed, 132 insertions(+), 7 deletions(-) create mode 100644 default.nix create mode 100644 shell.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..3f49833 --- /dev/null +++ b/default.nix @@ -0,0 +1,118 @@ +{ + pkgs, + python ? pkgs.python39, + ...}: +let + urlobject = with python.pkgs; buildPythonPackage rec { + pname = "URLObject"; + version = "2.4.3"; + src = fetchPypi { + inherit pname version; + sha256 = "47b2e20e6ab9c8366b2f4a3566b6ff4053025dad311c4bb71279bbcfa2430caa"; + }; + doCheck = true; + propagatedBuildInputs = [ + ]; + + }; + + + flask-dance = with python.pkgs; buildPythonPackage rec { + pname = "Flask-Dance"; + version = "5.1.0"; + src = fetchPypi { + inherit pname version; + sha256 = "9eb5a404ef1b06a58aabbe5ac496908bda0482af1cf08e8c00188493405842fd"; + }; + doCheck = false; + propagatedBuildInputs = [ + requests + oauthlib + requests_oauthlib + flask + urlobject + ]; + checkInputs = [ + pytest + pytest-mock + responses + freezegun + coverage +# testing sqlalchemy support + sqlalchemy + flask_sqlalchemy +# testing integration with other extensions + flask_login + flask-caching + betamax +# we need the `signedtoken` extra for `oauthlib` +# oauthlib[signedtoken] + ]; + + }; + ldap3-orm = with python.pkgs; buildPythonPackage rec { + pname = "ldap3-orm"; + version = "2.7.0"; + src = fetchPypi { + inherit pname version; + sha256 = "8783886d4ce90d66da61ce24619593a265b50f0de1fbebe86df95c6788661664"; + }; + doCheck = false; + propagatedBuildInputs = [ + ldap3 + six + ]; + + }; + u2flib-server = {}; + ory-hydra-client = with python.pkgs; buildPythonPackage rec { + pname = "ory-hydra-client"; + version = "1.10.6"; + src = fetchPypi { + inherit pname version; + sha256 = "57f877e55a8f202db27f5cbae9c55a1b1a91848ef46d0cbd3b710ef77882095c"; + }; + doCheck = false; + propagatedBuildInputs = [ + urllib3 + python-dateutil + ]; + + }; +in +{ + nativeBuildInputs = with python.pkgs; [ + flask + flask-restful + flask_sqlalchemy + flask_wtf + flask-babel + flask_login + requests + requests_oauthlib + ldap3 + ldap3-orm + pyotp + cryptography + blinker + ory-hydra-client + + gunicorn + + flask-dance + +#python-u2flib-server + + +#flask-debug + + ]; + + testBuildInputs = with python.pkgs; [ + pytest + pytest-mypy + flask_testing + tox + mypy + ]; +} diff --git a/lenticular_cloud/app.py b/lenticular_cloud/app.py index bdae7a5..7301e93 100644 --- a/lenticular_cloud/app.py +++ b/lenticular_cloud/app.py @@ -1,12 +1,12 @@ from flask.app import Flask from flask import g, redirect, request from flask.helpers import url_for -from jwkest.jwk import RSAKey, rsa_load from flask_babel import Babel from flask_login import LoginManager import time import subprocess import ory_hydra_client as hydra +import ory_hydra_client.api.admin_api as hydra_admin_api from ldap3 import Connection, Server, ALL @@ -55,7 +55,7 @@ def init_app(name=None): username=app.config['HYDRA_ADMIN_USER'], password=app.config['HYDRA_ADMIN_PASSWORD']) hydra_client = hydra.ApiClient(hydra_config) - app.hydra_api = hydra.AdminApi(hydra_client) + app.hydra_api = hydra_admin_api.AdminApi(hydra_client) from .views import auth_views, frontend_views, init_login_manager, api_views, pki_views, admin_views init_login_manager(app) diff --git a/lenticular_cloud/views/api.py b/lenticular_cloud/views/api.py index 3846f99..11cf849 100644 --- a/lenticular_cloud/views/api.py +++ b/lenticular_cloud/views/api.py @@ -4,7 +4,6 @@ from flask import current_app, session from flask import jsonify from flask.helpers import make_response from flask.templating import render_template -from oic.oic.message import TokenErrorResponse, UserInfoErrorResponse, EndSessionRequest from flask import Blueprint, render_template, request, url_for import logging diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..fbc1874 --- /dev/null +++ b/shell.nix @@ -0,0 +1,12 @@ +{ + pkgs ? import {}, + python ? pkgs.python39 +}: +let + settings = import ./default.nix {inherit pkgs python;}; +in +pkgs.mkShell { + # nativeBuildInputs is usually what you want -- tools you need to run + nativeBuildInputs = settings.nativeBuildInputs ++ settings.testBuildInputs; +} + diff --git a/templates/frontend/client_cert_new.html.j2 b/templates/frontend/client_cert_new.html.j2 index 882ee7f..c03f3d6 100644 --- a/templates/frontend/client_cert_new.html.j2 +++ b/templates/frontend/client_cert_new.html.j2 @@ -42,8 +42,4 @@ {% endblock %} -{% block script_js %} - - -{% endblock %}