Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed sig verification error to 401;changed action url #246

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions backend/api/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from ..settings import Settings

from fastapi import Depends
from fastapi import Depends, HTTPException
from fastapi_jwt_auth import AuthJWT
from fastapi_jwt_auth.exceptions import JWTDecodeError

from passlib import pwd
from passlib.context import CryptContext
Expand Down Expand Up @@ -31,4 +32,10 @@ def auth_check(Authorize):
if settings.DISABLE_AUTH == "True":
return
else:
return Authorize.jwt_required()
try:
return Authorize.jwt_required()
except JWTDecodeError as exc:
status_code = exc.status_code
if exc.message == "Signature verification failed":
status_code = 401
raise HTTPException(status_code=status_code, detail=exc.message)
4 changes: 2 additions & 2 deletions backend/api/routers/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_project(project_name, Authorize: AuthJWT = Depends()):
return get_compose(project_name)


@router.get("/{project_name}/{action}")
@router.get("/{project_name}/actions/{action}")
def get_compose_action(project_name, action, Authorize: AuthJWT = Depends()):
auth_check(Authorize)
if action == "delete":
Expand All @@ -42,7 +42,7 @@ def write_compose_project(
auth_check(Authorize)
return write_compose(compose=compose)

@router.get("/{project_name}/{action}/{app}")
@router.get("/{project_name}/actions/{action}/{app}")
def get_compose_app_action(project_name, action, app, Authorize: AuthJWT = Depends()):
auth_check(Authorize)
return compose_app_action(project_name, action, app)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function createAxiosResponseInterceptor() {
const interceptor = axios.interceptors.response.use(
response => response,
error => {
if (error.response.status !== 401 || error.response.status !== 403) {
if (error.response.status !== 401) {
return Promise.reject(error);
}

Expand All @@ -35,7 +35,7 @@ function createAxiosResponseInterceptor() {
return axios(error.response.config);
})
.catch(error => {
if (error.response.status !== 401 || error.response.status !== 403) {
if (error.response.status !== 401) {
return Promise.reject(error);
} else {
store.dispatch("auth/AUTH_LOGOUT");
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/store/modules/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const actions = {
},
ProjectAction({ commit, dispatch }, { Name, Action }) {
commit("setLoading", true);
const url = `/api/compose/${Name}/${Action}`;
const url = `/api/compose/actions/${Name}/${Action}`;
axios
.get(url)
.then(response => {
Expand All @@ -128,7 +128,7 @@ const actions = {
},
ProjectAppAction({ commit, dispatch }, { Project, Name, Action }) {
commit("setLoading", true);
const url = `/api/compose/${Project}/${Action}/${Name}`;
const url = `/api/compose/${Project}/actions/${Action}/${Name}`;
axios
.get(url)
.then(response => {
Expand Down