add: caddy jwt logic

v0.7
rrr-marble 3 years ago
parent b89fcc40fd
commit e34355cc7b

@ -16,7 +16,7 @@ from .database import SessionLocal, engine
# Security # Security
# take it from env # take it from env
SECRET_KEY = b64decode("iYg7wB+sPihtjz50iJTsD0XmOeUwKy2TJtfNLcqFRM8=").hex() SECRET_KEY = b64decode("iYg7wB+sPihtjz50iJTsD0XmOeUwKy2TJtfNLcqFRM8=")
ALGORITHM = "HS256" ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 3600 ACCESS_TOKEN_EXPIRE_MINUTES = 3600

@ -1,36 +1,46 @@
{
order jwtauth before basicauth
}
:80 { :80 {
encode zstd gzip encode zstd gzip
handle_path /api/v1/* { handle_path /api/v1/* {
rewrite * {path} rewrite * {path}
reverse_proxy geodata:8000 reverse_proxy geodata:8000
} }
redir /openapi.json /api/v1/openapi.json permanent redir /openapi.json /api/v1/openapi.json permanent
handle_path /martin/* {
rewrite * {path}
reverse_proxy martin:3000
}
handle_path /martin/* { @is_admin {
rewrite * {path} vars {http.auth.user.id} "demo"
reverse_proxy martin:3000 }
}
handle_path /pgweb/* {
jwtauth {
sign_key iYg7wB+sPihtjz50iJTsD0XmOeUwKy2TJtfNLcqFRM8=
}
handle_path /pgweb/* { rewrite * {path}
rewrite * {path} reverse_proxy @is_admin pgweb:8081
reverse_proxy pgweb:8081 redir /login/ 401
} }
handle_path /static/previews/* { handle_path /static/previews/* {
rewrite * {path} rewrite * {path}
file_server file_server
} }
# play nice with vue-router # play nice with vue-router
# https://caddy.community/t/caddy-with-vue-router/12352 # https://caddy.community/t/caddy-with-vue-router/12352
handle { handle {
root * /usr/share/caddy root * /usr/share/caddy
try_files {path}.html {path} /index.html try_files {path}.html {path} /index.html
file_server file_server
} }
} }

Loading…
Cancel
Save