Commit 495ce750 authored by Olha Zamirets's avatar Olha Zamirets
Browse files

build: Separate auth lib functionality

parent 34cc88b1
......@@ -23,9 +23,6 @@ helm-kubeval:
build-new-image:
extends: .build-new-image-template
test-unit:
extends: .test-unit-template
test-integration:
extends: .test-integration-template
......@@ -43,20 +40,12 @@ publish-coverage-report:
cleanup-test-images:
extends: .cleanup-test-images-template
build-wheel:
extends: .build-wheel-template
publish-wheel:
extends: .publish-wheel-template
build-helm-package:
extends: .build-helm-package-template
artifacts:
paths:
- auth-*.tgz
push-image:
extends: .push-to-registry-template
......
......@@ -7,7 +7,6 @@ CI_COMMIT_REF_NAME ?= ''
CI_PIPELINE_ID ?= 1
COMPOSE_PROJECT_NAME ?= $(PROJECT_NAME)-$(CI_PIPELINE_ID)
PROJECT_ID ?= $(COMPOSE_PROJECT_NAME)-$(CI_COMMIT_SHORT_SHA)
PROJECT_ID_UNIT=$(PROJECT_ID)-unit
PROJECT_ID_INTEGRATION ?= $(PROJECT_ID)-integration
PUBLISH_STAGE_CONTAINER_NAME ?= $(PROJECT_ID)-publish
......@@ -69,15 +68,6 @@ docker-build:
--build-arg twine_password=$(TWINE_PASSWORD) \
-t $(IMAGE_TEST) .
## Runs unit tests | Tests
test-unit: $(REBUILD_IMAGES_FOR_TESTS)
@docker rm -f $(PROJECT_ID_UNIT) || true
@docker-compose -p $(PROJECT_ID_UNIT) \
run --name $(PROJECT_ID_UNIT) \
$(PROJECT_NAME)-test-unit pytest -v -q --cov-report= --cov=prozorro_sale test/unit
@docker cp $(PROJECT_ID_UNIT):/$(PROJECT_NAME)/.coverage .coverage.unit
@docker-compose -p $(PROJECT_ID_UNIT) stop
## Runs integration tests
test-integration: $(REBUILD_IMAGES_FOR_TESTS)
@docker rm -f $(PROJECT_ID_INTEGRATION) || true
......@@ -122,7 +112,6 @@ push-helm-package:
publish-coverage:
@docker rm -f $(PUBLISH_STAGE_CONTAINER_NAME) || true
@docker run -d --name $(PUBLISH_STAGE_CONTAINER_NAME) $(IMAGE_TEST) sleep infinity
@docker cp .coverage.unit $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/
@docker cp .coverage.integration $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/
@docker exec $(PUBLISH_STAGE_CONTAINER_NAME) bash -c "cd /tmp && coverage combine && coverage report && coverage html -d cover-html"
@docker cp $(PUBLISH_STAGE_CONTAINER_NAME):/tmp/cover-html cover-html
......@@ -136,14 +125,6 @@ version:
git log --oneline --no-decorate --no-merges $(GIT_TAG)..HEAD >> Changelog-$(VERSION).txt
git tag -a -e -F Changelog-$(VERSION).txt $(VERSION)
## Build python package
build-wheel:
@python3 setup.py $(EGG_INFO) sdist bdist_wheel
## Publish python package
publish-wheel:
twine upload --skip-existing dist/*
## Shows help. | Help
help:
@echo ''
......
......@@ -4,7 +4,7 @@ ipaddress = "*"
cryptography = "*"
prozorro-aiohttp-swagger = {version="*", index="prozorro"}
prozorro-tools = {version="~=0.14", index="prozorro"}
PyYAML = "*"
prozorro-auth = {version=">=0.19.0", index="prozorro"}
PyJWT = "~=2.0.0"
pymongo = "<4"
uvloop = "*"
......
{
"_meta": {
"hash": {
"sha256": "72ad1cbc804795e178d0b73ba9a2818b3cc4f3ff4f461cf668f4a593145dd89f"
"sha256": "5e6efce1b5d9033e7e9f3661a31bcd6d9ff7636a7c434ed219d8d1ec2f89d2d4"
},
"pipfile-spec": 6,
"requires": {},
......@@ -117,19 +117,19 @@
},
"async-timeout": {
"hashes": [
"sha256:a22c0b311af23337eb05fcf05a8b51c3ea53729d46fb5460af62bee033cec690",
"sha256:b930cb161a39042f9222f6efb7301399c87eeab394727ec5437924a36d6eef51"
"sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15",
"sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"
],
"markers": "python_version >= '3.6'",
"version": "==4.0.1"
"version": "==4.0.2"
},
"attrs": {
"hashes": [
"sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1",
"sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"
"sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4",
"sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.2.0"
"version": "==21.4.0"
},
"brotli": {
"hashes": [
......@@ -277,35 +277,34 @@
"sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721",
"sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c"
],
"markers": "python_full_version >= '3.5.0'",
"markers": "python_version >= '3.5'",
"version": "==2.0.9"
},
"cryptography": {
"hashes": [
"sha256:2049f8b87f449fc6190350de443ee0c1dd631f2ce4fa99efad2984de81031681",
"sha256:231c4a69b11f6af79c1495a0e5a85909686ea8db946935224b7825cfb53827ed",
"sha256:24469d9d33217ffd0ce4582dfcf2a76671af115663a95328f63c99ec7ece61a4",
"sha256:2deab5ec05d83ddcf9b0916319674d3dae88b0e7ee18f8962642d3cde0496568",
"sha256:494106e9cd945c2cadfce5374fa44c94cfadf01d4566a3b13bb487d2e6c7959e",
"sha256:4c702855cd3174666ef0d2d13dcc879090aa9c6c38f5578896407a7028f75b9f",
"sha256:52f769ecb4ef39865719aedc67b4b7eae167bafa48dbc2a26dd36fa56460507f",
"sha256:5c49c9e8fb26a567a2b3fa0343c89f5d325447956cc2fc7231c943b29a973712",
"sha256:684993ff6f67000a56454b41bdc7e015429732d65a52d06385b6e9de6181c71e",
"sha256:6fbbbb8aab4053fa018984bb0e95a16faeb051dd8cca15add2a27e267ba02b58",
"sha256:8982c19bb90a4fa2aad3d635c6d71814e38b643649b4000a8419f8691f20ac44",
"sha256:9511416e85e449fe1de73f7f99b21b3aa04fba4c4d335d30c486ba3756e3a2a6",
"sha256:97199a13b772e74cdcdb03760c32109c808aff7cd49c29e9cf4b7754bb725d1d",
"sha256:a776bae1629c8d7198396fd93ec0265f8dd2341c553dc32b976168aaf0e6a636",
"sha256:aa94d617a4cd4cdf4af9b5af65100c036bce22280ebb15d8b5262e8273ebc6ba",
"sha256:b17d83b3d1610e571fedac21b2eb36b816654d6f7496004d6a0d32f99d1d8120",
"sha256:d73e3a96c38173e0aa5646c31bf8473bc3564837977dd480f5cbeacf1d7ef3a3",
"sha256:d91bc9f535599bed58f6d2e21a2724cb0c3895bf41c6403fe881391d29096f1d",
"sha256:ef216d13ac8d24d9cd851776662f75f8d29c9f2d05cdcc2d34a18d32463a9b0b",
"sha256:f6a5a85beb33e57998dc605b9dbe7deaa806385fdf5c4810fb849fcd04640c81",
"sha256:f92556f94e476c1b616e6daec5f7ddded2c082efa7cee7f31c7aeda615906ed8"
"sha256:0a817b961b46894c5ca8a66b599c745b9a3d9f822725221f0e0fe49dc043a3a3",
"sha256:2d87cdcb378d3cfed944dac30596da1968f88fb96d7fc34fdae30a99054b2e31",
"sha256:30ee1eb3ebe1644d1c3f183d115a8c04e4e603ed6ce8e394ed39eea4a98469ac",
"sha256:391432971a66cfaf94b21c24ab465a4cc3e8bf4a939c1ca5c3e3a6e0abebdbcf",
"sha256:39bdf8e70eee6b1c7b289ec6e5d84d49a6bfa11f8b8646b5b3dfe41219153316",
"sha256:4caa4b893d8fad33cf1964d3e51842cd78ba87401ab1d2e44556826df849a8ca",
"sha256:53e5c1dc3d7a953de055d77bef2ff607ceef7a2aac0353b5d630ab67f7423638",
"sha256:596f3cd67e1b950bc372c33f1a28a0692080625592ea6392987dba7f09f17a94",
"sha256:5d59a9d55027a8b88fd9fd2826c4392bd487d74bf628bb9d39beecc62a644c12",
"sha256:6c0c021f35b421ebf5976abf2daacc47e235f8b6082d3396a2fe3ccd537ab173",
"sha256:73bc2d3f2444bcfeac67dd130ff2ea598ea5f20b40e36d19821b4df8c9c5037b",
"sha256:74d6c7e80609c0f4c2434b97b80c7f8fdfaa072ca4baab7e239a15d6d70ed73a",
"sha256:7be0eec337359c155df191d6ae00a5e8bbb63933883f4f5dffc439dac5348c3f",
"sha256:94ae132f0e40fe48f310bba63f477f14a43116f05ddb69d6fa31e93f05848ae2",
"sha256:bb5829d027ff82aa872d76158919045a7c1e91fbf241aec32cb07956e9ebd3c9",
"sha256:ca238ceb7ba0bdf6ce88c1b74a87bffcee5afbfa1e41e173b1ceb095b39add46",
"sha256:ca28641954f767f9822c24e927ad894d45d5a1e501767599647259cbf030b903",
"sha256:e0344c14c9cb89e76eb6a060e67980c9e35b3f36691e15e1b7a9e58a0a6c6dc3",
"sha256:ebc15b1c22e55c4d5566e3ca4db8689470a0ca2babef8e3a9ee057a8b82ce4b1",
"sha256:ec63da4e7e4a5f924b90af42eddf20b698a70e58d86a72d943857c4c6045b3ee"
],
"index": "prozorro",
"version": "==36.0.0"
"version": "==36.0.1"
},
"frozenlist": {
"hashes": [
......@@ -390,7 +389,7 @@
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
],
"markers": "python_full_version >= '3.5.0'",
"markers": "python_version >= '3.5'",
"version": "==3.3"
},
"ipaddress": {
......@@ -552,12 +551,19 @@
"index": "prozorro",
"version": "==1.0.15.post20210723"
},
"prozorro-auth": {
"hashes": [
"sha256:d1d8f2afd75a3781c3f9c83af757b8c020605bd187af8c52a3973e99e8ec03c8"
],
"index": "prozorro",
"version": "==0.21.2.post20211222"
},
"prozorro-tools": {
"hashes": [
"sha256:9cb34292f060ea533944520d31d8a75180fb69d18c803e4e9254caca56a19a48"
"sha256:099382b2baf12fa35832f12891a369932f84d2c1203a751c0d08b6287a9371dc"
],
"index": "prozorro",
"version": "==0.14.0"
"version": "==0.14.0.post20211221"
},
"pycares": {
"hashes": [
......@@ -727,7 +733,7 @@
"sha256:32b2bdc1873fd3a3c346da1c6db83d0053c3c62f28f1f38516070c4c8971b1d3",
"sha256:a5de49a31e953b45ff2d2fd434bbc2670e8db5273606c1e737cc6b93eff3655f"
],
"markers": "python_full_version >= '3.5.0'",
"markers": "python_version >= '3.5'",
"version": "==0.19.2"
},
"pyyaml": {
......@@ -766,66 +772,64 @@
"sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",
"sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"
],
"index": "prozorro",
"version": "==6.0"
},
"typing-extensions": {
"hashes": [
"sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e",
"sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"
],
"markers": "python_version >= '3.6'",
"version": "==4.0.1"
"version": "==6.0"
},
"ujson": {
"hashes": [
"sha256:00fd67952b1a8a46cf5b0a51b3838187332d13d2e8d178423c5a5405c21d9e7c",
"sha256:01d12df8eb25afb939a003284b5b5adca9788c1176c445641e5980fa892562ac",
"sha256:087cd977f4f63f885a49607244e7e157801a22aadcc075a262d3c3633138573c",
"sha256:0c81159d3f1bcb5729ba019e63e78ee6c91b556e1ac0e67c7579768720fd3c4e",
"sha256:103cbabe4e6fd70c957219519e37d65be612d7c74d91ef19022a2c8f8c5e4e82",
"sha256:1601354caaab0697a9b24815a31611ad013d29cf957d545fc1cd59835b82e3c1",
"sha256:18040475d997d93a6851d8bee474fba2ec94869e8f826dddd66cdae4aa3fdb92",
"sha256:1f211c7c0c9377cbf4650aa990118d0c2cce3c5fad476c39ecd35b6714ba4463",
"sha256:294e907f134fb5d83e0a4439cf4040d74da77157938b4db5730cd174621dcf8b",
"sha256:2a06006dad34c8cfaa734bd6458452e46702b368da53b56e7732351082aa0420",
"sha256:327ec982bb89abe779fe463e1013c47aae6ed53b76600af7cb1e8b8cb0ee9f85",
"sha256:32ee97ec37af31b35ca4395732d883bf74fb70309d38485f7fb9a5cc3332c53e",
"sha256:3609e0514f6f721c6c9818b9374ec91b994e59fb193af2f924ca3f2f32009f1c",
"sha256:3d8eaab72ad8129c12ed90ebf310230bd014b6bbf99145ebf2bc890238e0254f",
"sha256:43d2403451d7bd27b6a600f89d4bd2cf6e1b3494254509d8b5ef3c8e94ae4d8e",
"sha256:47af81df5d575e36d4be9396db94f35c8f62de3077a405f9af94f9756255cef5",
"sha256:4f35dcf6d2a67e913a7135809006bd000d55ad5b5834b5dbe5b82dcf8db1ac05",
"sha256:5d1083a0dcb39b43cfcd948f09e480c23eb4af66d7d08f6b36951f4c629c3bd1",
"sha256:6df94e675b05ecf4e7a57883a73b916ffcb5872d7b1298ac5cef8ac1cbce73c6",
"sha256:7a318df321d7adc3de876b29640cca8de1ad4d4e4fe7c4a76d64d9d6f1676304",
"sha256:7b0a63865ec2978ebafb0906bf982eb52bea26fc98e2ae5e59b9d204afe2d762",
"sha256:843fd8b3246b2b20bbae48b2334d26507c9531b2b014533adfc6132e3ec8e60c",
"sha256:85f28c38952b8a94183ab15ec6c6e89c117d00ceeae5d754ef1a33e01e28b845",
"sha256:8a0d9dde58937976cd06cd776411b77b0e5d38db0a3c1be28ee8bb428ff5a42b",
"sha256:9baa160ba1d3f712a356e77718251c9d9eee43ed548debdcc9d75b06a75b3e82",
"sha256:9c5330692122b999997911252466a7d17e4e428d7d9a8db0b99ba81b8b9c010c",
"sha256:9f4a34386785a33600ac7442fec34c3d8b2d7e5309cfc94bc7c9ba93f12640c2",
"sha256:a6c32356145d95a0403b5895d60c36798a48af13b8863e43ad7457a0361afad0",
"sha256:b0b9cde57eebaac26de040f8ebf0541e06fe9bcf7e42872dc036d2ced7d99ccf",
"sha256:b0e9510e867c72a87db2d16377c2bef912f29afd8381d1fdae332b9b7f697efa",
"sha256:b270088e472f1d65a0a0aab3190010b9ac1a5b2969d39bf2b53c0fbf339bc87a",
"sha256:b72fadeea5727204674c9f77166da7feaafdf70f1ed50bb15bf321f7c39c7194",
"sha256:b80a35bad8fad1772f992bae8086b0cde788cd3b37f35d0d4506c93e6edad645",
"sha256:b850029d64008e970cae04ada69aa33e1cd412106a1efde221269c1cda1b40cc",
"sha256:baee56eca35cb5fbe02c28bd9c0936be41a96fa5c0812d9d4b7edeb5c3d568a0",
"sha256:bf199015910fcfa19b6e12881abeb462498791b2ab0111ff8b17095d0477e9d4",
"sha256:d8e2a52fbeee55db306b9306892f5cde7e78c56069c1212abf176d1886fff60a",
"sha256:de42986e2602b6a0baca452ff50e9cbe66faf256761295d5d07ae3f6757b487d",
"sha256:df481d4e13ca34d870d1fdf387742867edff3f78a1eea1bbcd72ea2fa68d9a6e",
"sha256:e46c1462761db518fae51ab0d89a6256aeac148a795f7244d9084c459b477af5",
"sha256:e7e73ec5ba1b42c2027773f69b70eff28df132907aa98b28166c39d3ea45e85b",
"sha256:f158fdb08e022f2f16f0fba317a80558b0cebc7e2c84ae783e5f75616d5c90d5",
"sha256:fc9a508efb829bf0542be9b2578d8da08f0ab1fa712e086ebb777d6ec9e6d8d2",
"sha256:fd0901db652a58f46550074596227dbddb7a02d2de744d3cd2358101f78037bb"
],
"markers": "python_version >= '3.6'",
"version": "==4.3.0"
"sha256:00d6ea9702c2eaeaf1a826934eaba1b4c609c873379bf54e36ba7b7e128edf94",
"sha256:05aa6c7297a22081f65497b6f586de6b7060ea47c3ecda80896f47200e9dbf04",
"sha256:06bed66ae62d517f67a61cf53c056800b35ef364270723168a1db62702e2d30c",
"sha256:08265db5ccff8b521ff68aee13a417d68cca784d7e711d961b92fda6ccffcc4f",
"sha256:083c1078e4de3a39019e590c43865b17e07a763fee25b012e650bb4f42c89703",
"sha256:0cae4a9c141856f7ad1a79c17ff1aaebf7fd8faa2f2c2614c37d6f82ed261d96",
"sha256:110633a8dda6c8ca78090292231e15381f8b2423e998399d4bc5f135149c722b",
"sha256:173b90a2c2836ee42f708df88ecfe3efbc4d868df73c9fcea8cb8f6f3ab93892",
"sha256:202ae52f4a53f03c42ead6d046b1a146517e93bd757f517bdeef0a26228e0260",
"sha256:31671ad99f0395eb881d698f2871dc64ff00fbd4380c5d9bfd8bff3d4c8f8d88",
"sha256:368f855779fded560724a6448838304621f498113a116d66bc5ed5ad5ad3ca92",
"sha256:4155a7c29bf330329519027c815e15e381c1fff22f50d26f135584d482bbd95d",
"sha256:452990c2b18445a7379a45873527d2ec47789b9289c13a17a3c1cc76b9641126",
"sha256:4ba63b789d83ca92237dbc72041a268d91559f981c01763a107105878bae442e",
"sha256:4dd97e45a0f450ba2c43cda18147e54b8e41e886c22e3506c62f7d61e9e53b0d",
"sha256:51142c9d40439f299594e399bef8892a16586ded54c88d3af926865ca221a177",
"sha256:5304ad25d100d50b5bc8513ef110335df678f66c7ccf3d4728c0c3aa69e08e0c",
"sha256:585271d6ad545a2ccfc237582f70c160e627735c89d0ca2bde24afa321bc0750",
"sha256:5c8a884d60dd2eed2fc95a9474d57ead82adf254f54caffb3d9e8ed185c49aba",
"sha256:644552d1e89983c08d0c24358fbcb5829ae5b5deee9d876e16d20085cfa7dc81",
"sha256:681fed63c948f757466eeb3aea98873e2ab8b2b18e9020c96a97479a513e2018",
"sha256:68e38122115a8097fbe1cfe52979a797eaff91c10c1bf4b27774e5f30e7f723a",
"sha256:6c45ad95e82155372d9908774db46e0ef7880af28a734d0b14eaa4f505e64982",
"sha256:6f73946c047a38640b1f5a2a459237b7bdc417ab028a76c796e4eea984b359b9",
"sha256:6fc4376266ae67f6d8f9e69386ab950eb84ba345c6fdbeb1884fa5b773c8c76b",
"sha256:74e41a0222e6e8136e38f103d6cc228e4e20f1c35cc80224a42804fd67fb35c8",
"sha256:7a4bed7bd7b288cf73ba47bda27fdd1d78ef6906831489e7f296aef9e786eccb",
"sha256:7ba8be1717b1867a85b2413a8585bad0e4507a22d6af2c244e1c74151f6d5cc0",
"sha256:7bbb87f040e618bebe8c6257b3e4e8ae2f708dcbff3270c84718b3360a152799",
"sha256:838d35eb9006d36f9241e95958d9f4819bcf1ea2ec155daf92d5751c31bcc62b",
"sha256:8dca10174a3bd482d969a2d12d0aec2fdd63fb974e255ec0147e36a516a2d68a",
"sha256:9937e819196b894ffd00801b24f1042dabda142f355313c3f20410993219bc4f",
"sha256:994eaf4369e6bc24258f59fe8c6345037abcf24557571814e27879851c4353aa",
"sha256:a48efcb5d3695b295c26835ed81048da8cd40e76c4fde2940c807aa452b560c9",
"sha256:a53c4fe8e1c067e6c98b4526e982ed9486f08578ad8eb5f0e94f8cadf0c1d911",
"sha256:a88944d2f99db71a3ca0c63d81f37e55b660edde0b07216fb65a3e46403ef004",
"sha256:afe91153c2046fa8210b92def513124e0ea5b87ad8fa4c14fef8197204b980f1",
"sha256:b09843123425337d2efee5c8ff6519e4dfc7b044db66c8bd560517fc1070a157",
"sha256:b1ef400fc73ab0cb61b74a662ad4207917223aba6f933a9fea9b0fbe75de2361",
"sha256:b2c7e4afde0d36926b091fa9613b18b65e911fcaa60024e8721f2dcfedc25329",
"sha256:b631af423e6d5d35f9f37fbcc4fbdb6085abc1c441cf864c64b7fbb5b150faf7",
"sha256:caeadbf95ce277f1f8f4f71913bc20c01f49fc9228f238920f9ff6f7645d2a5f",
"sha256:ce441ab7ad1db592e2db95b6c2a1eb882123532897340afac1342c28819e9833",
"sha256:ce620a6563b21aa3fbb1658bc1bfddb484a6dad542de1efb5121eb7bb4f2b93a",
"sha256:d0b26d9d6eb9a0979d37f28c715e717a409c9e03163e5cd8fa73aab806351ab5",
"sha256:d423956f8dfd98a075c9338b886414b6e3c2817dbf67935797466c998af39936",
"sha256:e2b1c372583eb4363b42e21222d3a18116a41973781d502d61e1b0daf4b8352f",
"sha256:fa616d0d3c594785c6e9b7f42686bb1c86f9e64aa0f30a72c86d8eb315f54194",
"sha256:fdac161127ef8e0889180a4c07475457c55fe0bbd644436d8f4c7ef07565d653",
"sha256:fe4e8f71e2fd42dce245bace7e2aa97dabef13926750a351eadca89a1e0f1abd"
],
"markers": "python_version >= '3.7'",
"version": "==5.1.0"
},
"uvloop": {
"hashes": [
......@@ -1051,26 +1055,26 @@
},
"async-timeout": {
"hashes": [
"sha256:a22c0b311af23337eb05fcf05a8b51c3ea53729d46fb5460af62bee033cec690",
"sha256:b930cb161a39042f9222f6efb7301399c87eeab394727ec5437924a36d6eef51"
"sha256:2163e1640ddb52b7a8c80d0a67a08587e5d245cc9c553a74a847056bc2976b15",
"sha256:8ca1e4fcf50d07413d66d1a5e416e42cfdf5851c981d679a09851a6853383b3c"
],
"markers": "python_version >= '3.6'",
"version": "==4.0.1"
"version": "==4.0.2"
},
"attrs": {
"hashes": [
"sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1",
"sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"
"sha256:2d27e3784d7a565d36ab851fe94887c5eccd6a463168875832a1be79c82828b4",
"sha256:626ba8234211db98e869df76230a137c4c40a12d72445c45d5f5b716f076e2fd"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.2.0"
"version": "==21.4.0"
},
"charset-normalizer": {
"hashes": [
"sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721",
"sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c"
],
"markers": "python_full_version >= '3.5.0'",
"markers": "python_version >= '3.5'",
"version": "==2.0.9"
},
"click": {
......@@ -1235,7 +1239,7 @@
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
],
"markers": "python_full_version >= '3.5.0'",
"markers": "python_version >= '3.5'",
"version": "==3.3"
},
"iniconfig": {
......@@ -1471,18 +1475,10 @@
},
"tomli": {
"hashes": [
"sha256:c6ce0015eb38820eaf32b5db832dbc26deb3dd427bd5f6556cf0acac2c214fee",
"sha256:f04066f68f5554911363063a30b108d2b5a5b1a010aa8b6132af78489fe3aade"
"sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224",
"sha256:c292c34f58502a1eb2bbb9f5bbc9a5ebc37bee10ffb8c2d6bbdfa8eb13cc14e1"
],
"version": "==1.2.2"
},
"typing-extensions": {
"hashes": [
"sha256:4ca091dea149f945ec56afb48dae714f21e8692ef22a395223bcd328961b6a0e",
"sha256:7f001e5ac290a0c0401508864c7ec868be4e701886d5b573a9528ed3973d9d3b"
],
"markers": "python_version >= '3.6'",
"version": "==4.0.1"
"version": "==2.0.0"
},
"watchgod": {
"hashes": [
......
......@@ -4,9 +4,6 @@ Auth module is one of the CBD3 python packages.
Provides functionality for authorization.
## Development guide
### Installation
`pip install -i https://pypi-int.prozorro.sale prozorro-auth`
### Auth file
CBD3 uses the `auth.yml` file to store broker's credentials
......@@ -86,52 +83,6 @@ brokers:
railwayCargo:
- procedure
- bids
```
### Usage
**Required**: call `load_auth` on start app, to load `auth.yml` into memory. The auth data will be available in variable `AUTH_FILE`.
#### AclContext
Object that keeps `user` data and `acc_token `
* `user` - user information from the auth file
* `acc_token` - token that proves that user is owner of some entity (ex. procedure, bids)
#### context_middleware
Middleware to store `AclContext` to `request._context`
* Gets `acc_token` from GET parameter `acc_token` or HEADER `X-Access-Token`
* Gets `auth_token` from HEADER `Authorization`
* Gets `user` by `auth_token` from the AUTH_FILE
* Create and store `AclContext` to `request._context`
#### check_access
Decorator to check that user exists and has access by ip.
#### access_middleware
Middleware to check that user exists and has access by ip. Allow all `GET` requests. Uses `check_access` decorator if request method is not `GET`.
#### user.has_access_to_object
Method to check that user has access to some specific entity (procedure/bid)
## CLI
Command `prozorro-sale-token` generate new token (uuid4) and hash (sha256) to store in auth file
Use `--token` argument to generate hash for existing token
Examples:
```
>>> prozorro-sale-token
---------------------PROZORRO.SALE AUTH ENCRYPTION---------------------
TOKEN: 3cceb049-086d-4988-bdd4-ae62bb2038ac
HASH: 1e622638aa1c7504230130a7814d39aff39cbe09d6dcac3c4be46a2cdfafe4b6
-----------------------------------------------------------------------
>>> prozorro-sale-token --token 3cceb049-086d-4988-bdd4-ae62bb2038ac
---------------------PROZORRO.SALE AUTH ENCRYPTION---------------------
TOKEN: 3cceb049-086d-4988-bdd4-ae62bb2038ac
HASH: 1e622638aa1c7504230130a7814d39aff39cbe09d6dcac3c4be46a2cdfafe4b6
-----------------------------------------------------------------------
```
# Running module locally
......@@ -156,7 +107,6 @@ make docker-build
## To run tests
```
make test-unit
make test-integration
```
......
......@@ -3,7 +3,7 @@ version: '3.3'
services:
auth-app: &base_app
image: "${IMAGE}"
command: python -m prozorro_sale.auth.api
command: python -m prozorro_sale.auth_service.api
environment: &base_app_environment
AUCTIONS_API: "http://0.0.0.0:7777"
AUTH_FILE: "/secrets/auth.yml"
......@@ -11,7 +11,7 @@ services:
auth-databridge:
<<: *base_app
command: python -m prozorro_sale.auth.databridge
command: python -m prozorro_sale.auth_service.databridge
auth-test-integration: &test_app
<<: *base_app
......@@ -27,7 +27,7 @@ services:
auth-local: &local_app
<<: *base_app
tty: true
command: adev runserver prozorro_sale/auth/api
command: adev runserver prozorro_sale/auth_service/api
environment: &local_app_environment
<<: *base_app_environment
DEBUG: 1
......@@ -44,7 +44,7 @@ services:
auth-databridge-local:
<<: *local_app
command: adev runserver --app-factory=create_databridge prozorro_sale/auth/databridge
command: adev runserver --app-factory=create_databridge prozorro_sale/auth_service/databridge
environment:
<<: *local_app_environment
AIO_PORT: 8082
......
......@@ -72,7 +72,7 @@ application:
- python
args:
- -m
- prozorro_sale.auth.api
- prozorro_sale.auth_service.api
databridge:
enabled: true
......@@ -80,4 +80,4 @@ application:
- python
args:
- -m
- prozorro_sale.auth.databridge
\ No newline at end of file
- prozorro_sale.auth_service.databridge
\ No newline at end of file
from setuptools import find_packages, setup
requirements = [
'aiohttp',
'ipaddress',
'cryptography',
'prozorro-aiohttp-swagger',
'prozorro-tools',
'PyYAML',
'PyJWT',
'uvloop'
]
dependency_links = [
'https://pypi-int.prozorro.sale/prozorro-aiohttp-swagger',
'https://pypi-int.prozorro.sale/prozorro-tools'
]
setup(
name='prozorro-auth',
version_format='{tag}',
setup_requires=['setuptools-git-version'],
packages=find_packages('src'),
package_dir={'': 'src'},
install_requires=requirements,
entry_points={
'console_scripts': ['prozorro-sale-token=prozorro_sale.auth.encryption:_cli'],
},
dependency_links=dependency_links
)
from dataclasses import dataclass
from typing import List, Dict, Optional, Callable
from aiohttp import web
from yaml import load
try:
from yaml import CSafeLoader as Loader # type: ignore
except ImportError: # pragma: no cover
from yaml import SafeLoader as Loader # type: ignore
import ipaddress
from prozorro_sale.tools import logger
from prozorro_sale.auth.environment import environment
from prozorro_sale.auth.encryption import hash_token
LOG = logger.get_custom_logger(__name__)
@dataclass
class BrokerInfo:
legal_name: Optional[dict] = None
class User:
def __init__(self, name: str, token: str, broker_info: Optional[BrokerInfo] = None,
ips: Optional[List[str]] = None, procedures: Optional[Dict[str, List[str]]] = None):
self.name = name
self.token = token
self.broker_info = broker_info
self.ips = ips
self.procedures = procedures
@property
def ips(self) -> Optional[List[ipaddress.IPv4Network]]:
return self.__ips
@ips.setter
def ips(self, value: Optional[List[str]]) -> None:
if value is None:
self.__ips = None
return
if isinstance(value, list):
self.__ips = [ipaddress.ip_network(v) for v in value]
return
raise TypeError('Value should be list of ips or None')
def _get_procedure_key(self, procedure: str) -> Optional[str]:
for procedure_key in self.procedures:
if procedure_key in procedure:
return procedure_key
def has_access_to_object(self, procedure: str, obj_name: str) -> bool:
if not self.procedures:
return False
procedure_key = self._get_procedure_key(procedure)
procedure_permissions = self.procedures.get(procedure_key, ())
if not procedure_permissions:
return False
return obj_name in procedure_permissions
def has_access_by_ip(self, ip: str) -> bool:
return not self.ips or self._ip_allowed(ip)
def _ip_allowed(self, ip: str) -> bool:
address = ipaddress.ip_address(ip)
for network in self.ips:
if address in network:
return True
return False
def __str__(self) -> str: