Add basic auth to healthcheck endpoint
This commit is contained in:
parent
a4e0f4ab54
commit
19ad84414a
7 changed files with 23 additions and 3 deletions
1
Pipfile
1
Pipfile
|
@ -24,3 +24,4 @@ aiohttp = "*"
|
||||||
apscheduler = "*"
|
apscheduler = "*"
|
||||||
pygithub = "*"
|
pygithub = "*"
|
||||||
python-dotenv = "*"
|
python-dotenv = "*"
|
||||||
|
aiohttp-basicauth = "*"
|
||||||
|
|
9
Pipfile.lock
generated
9
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "b0d2de2b0b35e9c52f6fd20d157bb51571a1c3a243d372f2a15dd7944ff2fb90"
|
"sha256": "655537d96ce2a47a7ef792ca2e0142c6ac9171fe41bffceea65fef4ca070f473"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -44,6 +44,13 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==4.0.0a0"
|
"version": "==4.0.0a0"
|
||||||
},
|
},
|
||||||
|
"aiohttp-basicauth": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:277d071c29256e10b4650f1bffee7c2007d914da0c2036e2ab621eb7b2096b2d"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.1.2"
|
||||||
|
},
|
||||||
"apscheduler": {
|
"apscheduler": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:6599bc78901ee7e9be85cbd073d9cc155c42d2bc867c5cde4d4d1cc339ebfbeb",
|
"sha256:6599bc78901ee7e9be85cbd073d9cc155c42d2bc867c5cde4d4d1cc339ebfbeb",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from apscheduler.schedulers.blocking import BlockingScheduler
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from apscheduler.schedulers.blocking import BlockingScheduler
|
||||||
|
|
||||||
|
|
||||||
def create_scheduler():
|
def create_scheduler():
|
||||||
scheduler = BlockingScheduler()
|
scheduler = BlockingScheduler()
|
||||||
|
|
|
@ -8,3 +8,5 @@ load_dotenv()
|
||||||
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
|
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
|
||||||
|
|
||||||
LOGGING_LEVEL = _nameToLevel[os.environ.get('LOGGING_LEVEL', 'INFO')]
|
LOGGING_LEVEL = _nameToLevel[os.environ.get('LOGGING_LEVEL', 'INFO')]
|
||||||
|
|
||||||
|
BASIC_AUTH = os.environ['BASIC_AUTH'].split(":")
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from aiohttp_basicauth import BasicAuthMiddleware
|
||||||
|
|
||||||
|
from actioner.settings import BASIC_AUTH
|
||||||
|
|
||||||
from .healthcheck import healthcheck
|
from .healthcheck import healthcheck
|
||||||
|
|
||||||
|
|
||||||
def get_server():
|
def get_server():
|
||||||
|
auth = BasicAuthMiddleware(username=BASIC_AUTH[0], password=BASIC_AUTH[1], force=False)
|
||||||
app = web.Application()
|
app = web.Application()
|
||||||
app.router.add_get("/healthcheck", healthcheck)
|
app.router.add_get("/healthcheck", auth.required(healthcheck))
|
||||||
return app
|
return app
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
|
||||||
from actioner.clients import github
|
from actioner.clients import github
|
||||||
|
|
||||||
|
|
||||||
|
|
2
setup.cfg
Normal file
2
setup.cfg
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[isort]
|
||||||
|
not_skip = __init__.py
|
Reference in a new issue