diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9dbd7ac Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 9bf9a17..24b7de9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ env/ tmp/ db.sqlite3 +source/app/conf/development/.env +source/app/conf/production/.env diff --git a/Pipfile b/Pipfile index b5617df..fc40d30 100644 --- a/Pipfile +++ b/Pipfile @@ -6,3 +6,6 @@ name = "pypi" [packages] Django = "==4.1.4" "django-bootstrap4" = "==22.3" + +pangea-sdk = "*" +django-environ = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 255de1d..cebf5d5 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "0dfcafc667c25f648c075515a2f06e934b8bd087f96e97a8699c8c8314dacf8f" + "sha256": "712bb1b2902293b3197fed358ef1045307a0dac6bd605652e330f97f1226eb34" }, "pipfile-spec": 6, "requires": {}, @@ -14,6 +14,21 @@ ] }, "default": { + "about-time": { + "hashes": [ + "sha256:586b329450c9387d1ae8c42d2db4f5b4c57a54508d0f1b7bb00322ffd5ce9f9b", + "sha256:96841beb3f9b5de1cbb323d2bdb0fa9abdecbc46f2d546b9b3c2483d23daa17a" + ], + "version": "==3.1.1" + }, + "alive-progress": { + "hashes": [ + "sha256:089757c8197f27ad972ba27e1060f6db92368d83c736884e159034fd74865323", + "sha256:5503ffca0a0607d5f0d24d3b10a718fe50e375470fa07602b246333eb7ec88ee" + ], + "markers": "python_version >= '3.7' and python_version < '4'", + "version": "==2.4.1" + }, "asgiref": { "hashes": [ "sha256:71e68008da809b957b7ee4b43dbccff33d1b23519fb8344e33f049897077afac", @@ -30,6 +45,127 @@ "markers": "python_full_version >= '3.6.0'", "version": "==4.11.1" }, + "certifi": { + "hashes": [ + "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3", + "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18" + ], + "markers": "python_version >= '3.6'", + "version": "==2022.12.7" + }, + "cffi": { + "hashes": [ + "sha256:00a9ed42e88df81ffae7a8ab6d9356b371399b91dbdf0c3cb1e84c03a13aceb5", + "sha256:03425bdae262c76aad70202debd780501fabeaca237cdfddc008987c0e0f59ef", + "sha256:04ed324bda3cda42b9b695d51bb7d54b680b9719cfab04227cdd1e04e5de3104", + "sha256:0e2642fe3142e4cc4af0799748233ad6da94c62a8bec3a6648bf8ee68b1c7426", + "sha256:173379135477dc8cac4bc58f45db08ab45d228b3363adb7af79436135d028405", + "sha256:198caafb44239b60e252492445da556afafc7d1e3ab7a1fb3f0584ef6d742375", + "sha256:1e74c6b51a9ed6589199c787bf5f9875612ca4a8a0785fb2d4a84429badaf22a", + "sha256:2012c72d854c2d03e45d06ae57f40d78e5770d252f195b93f581acf3ba44496e", + "sha256:21157295583fe8943475029ed5abdcf71eb3911894724e360acff1d61c1d54bc", + "sha256:2470043b93ff09bf8fb1d46d1cb756ce6132c54826661a32d4e4d132e1977adf", + "sha256:285d29981935eb726a4399badae8f0ffdff4f5050eaa6d0cfc3f64b857b77185", + "sha256:30d78fbc8ebf9c92c9b7823ee18eb92f2e6ef79b45ac84db507f52fbe3ec4497", + "sha256:320dab6e7cb2eacdf0e658569d2575c4dad258c0fcc794f46215e1e39f90f2c3", + "sha256:33ab79603146aace82c2427da5ca6e58f2b3f2fb5da893ceac0c42218a40be35", + "sha256:3548db281cd7d2561c9ad9984681c95f7b0e38881201e157833a2342c30d5e8c", + "sha256:3799aecf2e17cf585d977b780ce79ff0dc9b78d799fc694221ce814c2c19db83", + "sha256:39d39875251ca8f612b6f33e6b1195af86d1b3e60086068be9cc053aa4376e21", + "sha256:3b926aa83d1edb5aa5b427b4053dc420ec295a08e40911296b9eb1b6170f6cca", + "sha256:3bcde07039e586f91b45c88f8583ea7cf7a0770df3a1649627bf598332cb6984", + "sha256:3d08afd128ddaa624a48cf2b859afef385b720bb4b43df214f85616922e6a5ac", + "sha256:3eb6971dcff08619f8d91607cfc726518b6fa2a9eba42856be181c6d0d9515fd", + "sha256:40f4774f5a9d4f5e344f31a32b5096977b5d48560c5592e2f3d2c4374bd543ee", + "sha256:4289fc34b2f5316fbb762d75362931e351941fa95fa18789191b33fc4cf9504a", + "sha256:470c103ae716238bbe698d67ad020e1db9d9dba34fa5a899b5e21577e6d52ed2", + "sha256:4f2c9f67e9821cad2e5f480bc8d83b8742896f1242dba247911072d4fa94c192", + "sha256:50a74364d85fd319352182ef59c5c790484a336f6db772c1a9231f1c3ed0cbd7", + "sha256:54a2db7b78338edd780e7ef7f9f6c442500fb0d41a5a4ea24fff1c929d5af585", + "sha256:5635bd9cb9731e6d4a1132a498dd34f764034a8ce60cef4f5319c0541159392f", + "sha256:59c0b02d0a6c384d453fece7566d1c7e6b7bae4fc5874ef2ef46d56776d61c9e", + "sha256:5d598b938678ebf3c67377cdd45e09d431369c3b1a5b331058c338e201f12b27", + "sha256:5df2768244d19ab7f60546d0c7c63ce1581f7af8b5de3eb3004b9b6fc8a9f84b", + "sha256:5ef34d190326c3b1f822a5b7a45f6c4535e2f47ed06fec77d3d799c450b2651e", + "sha256:6975a3fac6bc83c4a65c9f9fcab9e47019a11d3d2cf7f3c0d03431bf145a941e", + "sha256:6c9a799e985904922a4d207a94eae35c78ebae90e128f0c4e521ce339396be9d", + "sha256:70df4e3b545a17496c9b3f41f5115e69a4f2e77e94e1d2a8e1070bc0c38c8a3c", + "sha256:7473e861101c9e72452f9bf8acb984947aa1661a7704553a9f6e4baa5ba64415", + "sha256:8102eaf27e1e448db915d08afa8b41d6c7ca7a04b7d73af6514df10a3e74bd82", + "sha256:87c450779d0914f2861b8526e035c5e6da0a3199d8f1add1a665e1cbc6fc6d02", + "sha256:8b7ee99e510d7b66cdb6c593f21c043c248537a32e0bedf02e01e9553a172314", + "sha256:91fc98adde3d7881af9b59ed0294046f3806221863722ba7d8d120c575314325", + "sha256:94411f22c3985acaec6f83c6df553f2dbe17b698cc7f8ae751ff2237d96b9e3c", + "sha256:98d85c6a2bef81588d9227dde12db8a7f47f639f4a17c9ae08e773aa9c697bf3", + "sha256:9ad5db27f9cabae298d151c85cf2bad1d359a1b9c686a275df03385758e2f914", + "sha256:a0b71b1b8fbf2b96e41c4d990244165e2c9be83d54962a9a1d118fd8657d2045", + "sha256:a0f100c8912c114ff53e1202d0078b425bee3649ae34d7b070e9697f93c5d52d", + "sha256:a591fe9e525846e4d154205572a029f653ada1a78b93697f3b5a8f1f2bc055b9", + "sha256:a5c84c68147988265e60416b57fc83425a78058853509c1b0629c180094904a5", + "sha256:a66d3508133af6e8548451b25058d5812812ec3798c886bf38ed24a98216fab2", + "sha256:a8c4917bd7ad33e8eb21e9a5bbba979b49d9a97acb3a803092cbc1133e20343c", + "sha256:b3bbeb01c2b273cca1e1e0c5df57f12dce9a4dd331b4fa1635b8bec26350bde3", + "sha256:cba9d6b9a7d64d4bd46167096fc9d2f835e25d7e4c121fb2ddfc6528fb0413b2", + "sha256:cc4d65aeeaa04136a12677d3dd0b1c0c94dc43abac5860ab33cceb42b801c1e8", + "sha256:ce4bcc037df4fc5e3d184794f27bdaab018943698f4ca31630bc7f84a7b69c6d", + "sha256:cec7d9412a9102bdc577382c3929b337320c4c4c4849f2c5cdd14d7368c5562d", + "sha256:d400bfb9a37b1351253cb402671cea7e89bdecc294e8016a707f6d1d8ac934f9", + "sha256:d61f4695e6c866a23a21acab0509af1cdfd2c013cf256bbf5b6b5e2695827162", + "sha256:db0fbb9c62743ce59a9ff687eb5f4afbe77e5e8403d6697f7446e5f609976f76", + "sha256:dd86c085fae2efd48ac91dd7ccffcfc0571387fe1193d33b6394db7ef31fe2a4", + "sha256:e00b098126fd45523dd056d2efba6c5a63b71ffe9f2bbe1a4fe1716e1d0c331e", + "sha256:e229a521186c75c8ad9490854fd8bbdd9a0c9aa3a524326b55be83b54d4e0ad9", + "sha256:e263d77ee3dd201c3a142934a086a4450861778baaeeb45db4591ef65550b0a6", + "sha256:ed9cb427ba5504c1dc15ede7d516b84757c3e3d7868ccc85121d9310d27eed0b", + "sha256:fa6693661a4c91757f4412306191b6dc88c1703f780c8234035eac011922bc01", + "sha256:fcd131dd944808b5bdb38e6f5b53013c5aa4f334c5cad0c72742f6eba4b73db0" + ], + "version": "==1.15.1" + }, + "charset-normalizer": { + "hashes": [ + "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845", + "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f" + ], + "markers": "python_full_version >= '3.6.0'", + "version": "==2.1.1" + }, + "contextlib2": { + "hashes": [ + "sha256:3fbdb64466afd23abaf6c977627b75b6139a5a3e8ce38405c5b413aed7a0471f", + "sha256:ab1e2bfe1d01d968e1b7e8d9023bc51ef3509bba217bb730cee3827e1ee82869" + ], + "markers": "python_version >= '3.6'", + "version": "==21.6.0" + }, + "cryptography": { + "hashes": [ + "sha256:093cb351031656d3ee2f4fa1be579a8c69c754cf874206be1d4cf3b542042804", + "sha256:0cc20f655157d4cfc7bada909dc5cc228211b075ba8407c46467f63597c78178", + "sha256:1b9362d34363f2c71b7853f6251219298124aa4cc2075ae2932e64c91a3e2717", + "sha256:1f3bfbd611db5cb58ca82f3deb35e83af34bb8cf06043fa61500157d50a70982", + "sha256:2bd1096476aaac820426239ab534b636c77d71af66c547b9ddcd76eb9c79e004", + "sha256:31fe38d14d2e5f787e0aecef831457da6cec68e0bb09a35835b0b44ae8b988fe", + "sha256:3b8398b3d0efc420e777c40c16764d6870bcef2eb383df9c6dbb9ffe12c64452", + "sha256:3c81599befb4d4f3d7648ed3217e00d21a9341a9a688ecdd615ff72ffbed7336", + "sha256:419c57d7b63f5ec38b1199a9521d77d7d1754eb97827bbb773162073ccd8c8d4", + "sha256:46f4c544f6557a2fefa7ac8ac7d1b17bf9b647bd20b16decc8fbcab7117fbc15", + "sha256:471e0d70201c069f74c837983189949aa0d24bb2d751b57e26e3761f2f782b8d", + "sha256:59b281eab51e1b6b6afa525af2bd93c16d49358404f814fe2c2410058623928c", + "sha256:731c8abd27693323b348518ed0e0705713a36d79fdbd969ad968fbef0979a7e0", + "sha256:95e590dd70642eb2079d280420a888190aa040ad20f19ec8c6e097e38aa29e06", + "sha256:a68254dd88021f24a68b613d8c51d5c5e74d735878b9e32cc0adf19d1f10aaf9", + "sha256:a7d5137e556cc0ea418dca6186deabe9129cee318618eb1ffecbd35bee55ddc1", + "sha256:aeaba7b5e756ea52c8861c133c596afe93dd716cbcacae23b80bc238202dc023", + "sha256:dc26bb134452081859aa21d4990474ddb7e863aa39e60d1592800a8865a702de", + "sha256:e53258e69874a306fcecb88b7534d61820db8a98655662a3dd2ec7f1afd9132f", + "sha256:ef15c2df7656763b4ff20a9bc4381d8352e6640cfeb95c2972c38ef508e75181", + "sha256:f224ad253cc9cea7568f49077007d2263efa57396a2f2f78114066fd54b5c68e", + "sha256:f8ec91983e638a9bcd75b39f1396e5c0dc2330cbd9ce4accefe68717e6779e0a" + ], + "markers": "python_version >= '3.6'", + "version": "==37.0.2" + }, "django": { "hashes": [ "sha256:0b223bfa55511f950ff741983d408d78d772351284c75e9f77d2b830b6b4d148", @@ -46,6 +182,116 @@ "index": "pypi", "version": "==22.3" }, + "django-environ": { + "hashes": [ + "sha256:bff5381533056328c9ac02f71790bd5bf1cea81b1beeb648f28b81c9e83e0a21", + "sha256:f21a5ef8cc603da1870bbf9a09b7e5577ab5f6da451b843dbcc721a7bca6b3d9" + ], + "index": "pypi", + "version": "==0.9.0" + }, + "grapheme": { + "hashes": [ + "sha256:44c2b9f21bbe77cfb05835fec230bd435954275267fea1858013b102f8603cca" + ], + "version": "==0.6.0" + }, + "idna": { + "hashes": [ + "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", + "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" + ], + "markers": "python_version >= '3.5'", + "version": "==3.4" + }, + "pangea-sdk": { + "hashes": [ + "sha256:d9723a527c1f37b24507208c25abfe62ab100cc1fcae67f067e6bf55ef00a022", + "sha256:f824f0da2f5f82c9bcbd71f500a943edf822395e094fc9d3dc3fcba524374644" + ], + "index": "pypi", + "version": "==1.1.0" + }, + "pycparser": { + "hashes": [ + "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9", + "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206" + ], + "version": "==2.21" + }, + "pydantic": { + "hashes": [ + "sha256:05a81b006be15655b2a1bae5faa4280cf7c81d0e09fcb49b342ebf826abe5a72", + "sha256:0b53e1d41e97063d51a02821b80538053ee4608b9a181c1005441f1673c55423", + "sha256:2b3ce5f16deb45c472dde1a0ee05619298c864a20cded09c4edd820e1454129f", + "sha256:2e82a6d37a95e0b1b42b82ab340ada3963aea1317fd7f888bb6b9dfbf4fff57c", + "sha256:301d626a59edbe5dfb48fcae245896379a450d04baeed50ef40d8199f2733b06", + "sha256:39f4a73e5342b25c2959529f07f026ef58147249f9b7431e1ba8414a36761f53", + "sha256:4948f264678c703f3877d1c8877c4e3b2e12e549c57795107f08cf70c6ec7774", + "sha256:4b05697738e7d2040696b0a66d9f0a10bec0efa1883ca75ee9e55baf511909d6", + "sha256:51bdeb10d2db0f288e71d49c9cefa609bca271720ecd0c58009bd7504a0c464c", + "sha256:55b1625899acd33229c4352ce0ae54038529b412bd51c4915349b49ca575258f", + "sha256:572066051eeac73d23f95ba9a71349c42a3e05999d0ee1572b7860235b850cc6", + "sha256:6a05a9db1ef5be0fe63e988f9617ca2551013f55000289c671f71ec16f4985e3", + "sha256:6dc1cc241440ed7ca9ab59d9929075445da6b7c94ced281b3dd4cfe6c8cff817", + "sha256:6e7124d6855b2780611d9f5e1e145e86667eaa3bd9459192c8dc1a097f5e9903", + "sha256:75d52162fe6b2b55964fbb0af2ee58e99791a3138588c482572bb6087953113a", + "sha256:78cec42b95dbb500a1f7120bdf95c401f6abb616bbe8785ef09887306792e66e", + "sha256:7feb6a2d401f4d6863050f58325b8d99c1e56f4512d98b11ac64ad1751dc647d", + "sha256:8775d4ef5e7299a2f4699501077a0defdaac5b6c4321173bcb0f3c496fbadf85", + "sha256:887ca463c3bc47103c123bc06919c86720e80e1214aab79e9b779cda0ff92a00", + "sha256:9193d4f4ee8feca58bc56c8306bcb820f5c7905fd919e0750acdeeeef0615b28", + "sha256:983e720704431a6573d626b00662eb78a07148c9115129f9b4351091ec95ecc3", + "sha256:990406d226dea0e8f25f643b370224771878142155b879784ce89f633541a024", + "sha256:9cbdc268a62d9a98c56e2452d6c41c0263d64a2009aac69246486f01b4f594c4", + "sha256:a48f1953c4a1d9bd0b5167ac50da9a79f6072c63c4cef4cf2a3736994903583e", + "sha256:a9a6747cac06c2beb466064dda999a13176b23535e4c496c9d48e6406f92d42d", + "sha256:a9f2de23bec87ff306aef658384b02aa7c32389766af3c5dee9ce33e80222dfa", + "sha256:b5635de53e6686fe7a44b5cf25fcc419a0d5e5c1a1efe73d49d48fe7586db854", + "sha256:b6f9d649892a6f54a39ed56b8dfd5e08b5f3be5f893da430bed76975f3735d15", + "sha256:b9a3859f24eb4e097502a3be1fb4b2abb79b6103dd9e2e0edb70613a4459a648", + "sha256:cd8702c5142afda03dc2b1ee6bc358b62b3735b2cce53fc77b31ca9f728e4bc8", + "sha256:d7b5a3821225f5c43496c324b0d6875fde910a1c2933d726a743ce328fbb2a8c", + "sha256:d88c4c0e5c5dfd05092a4b271282ef0588e5f4aaf345778056fc5259ba098857", + "sha256:eb992a1ef739cc7b543576337bebfc62c0e6567434e522e97291b251a41dad7f", + "sha256:f2f7eb6273dd12472d7f218e1fef6f7c7c2f00ac2e1ecde4db8824c457300416", + "sha256:fdf88ab63c3ee282c76d652fc86518aacb737ff35796023fae56a65ced1a5978", + "sha256:fdf8d759ef326962b4678d89e275ffc55b7ce59d917d9f72233762061fd04a2d" + ], + "markers": "python_version >= '3.7'", + "version": "==1.10.4" + }, + "python-dateutil": { + "hashes": [ + "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86", + "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==2.8.2" + }, + "requests": { + "hashes": [ + "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983", + "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349" + ], + "markers": "python_version >= '3.7' and python_version < '4'", + "version": "==2.28.1" + }, + "schema": { + "hashes": [ + "sha256:f06717112c61895cabc4707752b88716e8420a8819d71404501e114f91043197", + "sha256:f3ffdeeada09ec34bf40d7d79996d9f7175db93b7a5065de0faa7f41083c1e6c" + ], + "version": "==0.7.5" + }, + "six": { + "hashes": [ + "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", + "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.16.0" + }, "soupsieve": { "hashes": [ "sha256:3b2503d3c7084a42b1ebd08116e5f81aadfaea95863628c80a3b774a11b7c759", @@ -61,6 +307,22 @@ ], "markers": "python_version >= '3.5'", "version": "==0.4.3" + }, + "typing-extensions": { + "hashes": [ + "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa", + "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e" + ], + "markers": "python_version >= '3.7'", + "version": "==4.4.0" + }, + "urllib3": { + "hashes": [ + "sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc", + "sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'", + "version": "==1.26.13" } }, "develop": {} diff --git a/README.md b/README.md index c5a8cfb..cdbca89 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,87 @@ -# Simple Django Login and Registration +# Pangea Django Example -An example of Django project with basic user functionality. +This is an example of Python Django project integrating with Pangea's [Audit Log](https://pangea.cloud/services/audit-log/) and [File Intel Services](https://pangea.cloud/services/file-intel/). -## Screenshots +In this example, you will see: How to integrate Pangea’s python SDK, Secure Audit Log, and File Intel service and also a File Upload feature in Python’s Django web framework. -| Log In | Create an account | Authorized page | -| -------|--------------|-----------------| -| | | | +Sample App is taken from [egorsmkv](https://github.com/egorsmkv/simple-django-login-and-register-dynamic-lang)'s Django Simple login and register example. -| Password reset | Set new password | Password change | -| ---------------|------------------|-----------------| -| | | | +## Prerequisites +* Python 3 +* A Pangea account - [sign up here](https://console.pangea.cloud/) +* [Create an API token](https://console.pangea.cloud/project/tokens) in Pangea Console for Secure Audit Log and File Intel Services +* Clone [this repo](https://github.com/pangeacyber/pangea-django-example) -## Functionality +## Installing Pangea Python SDK -- Log in - - via username & password - - via email & password - - via email or username & password - - with a remember me checkbox (optional) -- Create an account -- Log out -- Profile activation via email -- Reset password -- Remind a username -- Resend an activation code -- Change password -- Change email -- Change profile -- Multilingual: English, French, Russian, Simplified Chinese and Spanish +The Pangea Python Django Sample contains separated logic for user accounts and app modules. source/accounts specifically contain login and registration flows, which this tutorial will focus on. -If you need dynamic URLs with the language code, check out https://github.com/egorsmkv/simple-django-login-and-register-dynamic-lang - -## Installing - -### Clone the project +First, add Pangea Python SDK as a dependency on the project. Open Pipfile in the project and add the lines below: ```bash -git clone https://github.com/egorsmkv/simple-django-login-and-register -cd simple-django-login-and-register +pangea-sdk = "*" +django-environ = "*" ``` -### Install dependencies & activate virtualenv +You are adding the [pangea-python-sdk](https://pangea.cloud/docs/sdk/python/) and [django-environ](https://django-environ.readthedocs.io/en/latest/) latest packages to the project. + +Run the commands below to install [pipenv](https://github.com/pypa/pipenv) (a python packaging & environment manager), install python dependencies, and activate the pipenv environment. ```bash pip install pipenv - + pipenv install pipenv shell ``` -### Configure the settings (connection to the database, connection to an SMTP server, and other options) - -1. Edit `source/app/conf/development/settings.py` if you want to develop the project. - -2. Edit `source/app/conf/production/settings.py` if you want to run the project in production. - -### Apply migrations +Run the below commands to start the app and create a new user account. ```bash python source/manage.py migrate + +python source/manage.py runserver ``` -### Collect static files (only on a production server) + +> Note: + +* Python 3 is the default version for this project. +* Instead of modifying the Pipfile, you can install the package by running pipenv install python-pangea + +## Configuring Pangea’s API Keys + +> Note: You generated API tokens to communicate with Pangea’s services in the previous section.Remember, API tokens are sensitive and should not be checked into your code. django-environ is being used to manage the environment variables through which the API tokens are accessed in the project. + +Rename the `source/app/conf/development/.env.example` file to `.env` and fill in the details below by going to the Pangea Console. ```bash -python source/manage.py collectstatic +PANGEA_DOMAIN= +PANGEA_AUDIT_TOKEN= +PANGEA_FILE_INTEL_TOKEN= ``` -### Running +Domain is the region where your application's services are hosted and consumed. The tokens give access to the respective services you enable in the Pangea Console. -#### A development server +Add the code below to `source/app/conf/development/settings`.py to import and configure the `django-environ` package. -Just run this command: +```python +import environ + +env = environ.Env() +environ.Env.read_env() +``` -```bash -python source/manage.py runserver +Below the constants in your code, add the Pangea API token and make it accessible in the entire application. + +```python +#Pangea +PANGEA_DOMAIN = env('PANGEA_DOMAIN') +PANGEA_AUDIT_TOKEN = env('PANGEA_AUDIT_TOKEN') +PANGEA_FILE_INTEL_TOKEN = env('PANGEA_FILE_INTEL_TOKEN') ``` + + +> Note: You can configure a different domain and API token configuration for a production environment. In this tutorial, you are configuring everything for development. + +Adding [Secure Audit Log Integration ->](https://github.com/pangeacyber/pangea-django-example/tree/2-secure-audit-log) + diff --git a/source/app/conf/development/.env.example b/source/app/conf/development/.env.example new file mode 100644 index 0000000..4010304 --- /dev/null +++ b/source/app/conf/development/.env.example @@ -0,0 +1,3 @@ +PANGEA_DOMAIN= +PANGEA_AUDIT_TOKEN= +PANGEA_FILE_INTEL_TOKEN= \ No newline at end of file diff --git a/source/app/conf/development/settings.py b/source/app/conf/development/settings.py index f7ec5b9..53aa70e 100644 --- a/source/app/conf/development/settings.py +++ b/source/app/conf/development/settings.py @@ -2,6 +2,10 @@ import warnings from django.utils.translation import gettext_lazy as _ from os.path import dirname +import environ + +env = environ.Env() +environ.Env.read_env() warnings.simplefilter('error', DeprecationWarning) @@ -92,14 +96,19 @@ }, ] -ENABLE_USER_ACTIVATION = True +ENABLE_USER_ACTIVATION = False DISABLE_USERNAME = False -LOGIN_VIA_EMAIL = True -LOGIN_VIA_EMAIL_OR_USERNAME = False +LOGIN_VIA_EMAIL = False +LOGIN_VIA_EMAIL_OR_USERNAME = True LOGIN_REDIRECT_URL = 'index' LOGIN_URL = 'accounts:log_in' USE_REMEMBER_ME = True +#Pangea +PANGEA_DOMAIN = env('PANGEA_DOMAIN') +PANGEA_AUDIT_TOKEN = env('PANGEA_AUDIT_TOKEN') +PANGEA_FILE_INTEL_TOKEN = env('PANGEA_FILE_INTEL_TOKEN') + RESTORE_PASSWORD_VIA_EMAIL_OR_USERNAME = False ENABLE_ACTIVATION_AFTER_EMAIL_CHANGE = True diff --git a/source/app/conf/production/.env.example b/source/app/conf/production/.env.example new file mode 100644 index 0000000..4010304 --- /dev/null +++ b/source/app/conf/production/.env.example @@ -0,0 +1,3 @@ +PANGEA_DOMAIN= +PANGEA_AUDIT_TOKEN= +PANGEA_FILE_INTEL_TOKEN= \ No newline at end of file