1{
2 lib,
3 fetchFromGitHub,
4 fetchpatch,
5 buildPythonPackage,
6 isPy3k,
7 flask,
8 mock,
9 unittestCheckHook,
10}:
11
12buildPythonPackage rec {
13 pname = "flask-seasurf";
14 version = "1.1.1";
15 disabled = !isPy3k;
16
17 src = fetchFromGitHub {
18 owner = "maxcountryman";
19 repo = "flask-seasurf";
20 rev = version;
21 hash = "sha256-L/ZUEqqHmsyXG5eShcITII36ttwQlZN5GBngo+GcCdw=";
22 };
23
24 patches = [
25 # Remove usage of deprecated flask._app_ctx_stack
26 (fetchpatch {
27 url = "https://github.com/maxcountryman/flask-seasurf/commit/9039764a4e44aeb1acb6ae7747deb438bee0826b.patch";
28 hash = "sha256-bVYzJN6MXzH3fNMknd2bh+04JlPJRkU0cLcWv+Rigqc=";
29 })
30 ./0001-Fix-with-new-dependency-versions.patch
31 ];
32
33 postPatch = ''
34 # Disable some tests, pytest is not supported
35 sed -i "s#\(\(test_header_set_on_post\|test_https_good_referer\|test_https_referer_check_disabled\)(self):\)#\1\n return#g" test_seasurf.py
36 '';
37
38 propagatedBuildInputs = [ flask ];
39
40 nativeCheckInputs = [
41 unittestCheckHook
42 mock
43 ];
44
45 pythonImportsCheck = [ "flask_seasurf" ];
46
47 meta = with lib; {
48 description = "A Flask extension for preventing cross-site request forgery";
49 homepage = "https://github.com/maxcountryman/flask-seasurf";
50 license = licenses.bsd3;
51 maintainers = with maintainers; [ zhaofengli ];
52 };
53}