Angular - Are admin files downloadable?

我的未来我决定 提交于 2021-02-08 06:46:34

问题


I have a website with Angular. I implemented the auth with jwt. I know we can prevent the user to go to the restricted routes with Angular Route Guard.

Usually in SPAs all routes (html) are downloadable. Just we handle unauthorized routes in server by responding 403 code. So it's safe that user can see the html bu can't get any data. But in a specific project, we even don't want user to be able to see the html of admin panel (Since he can know about structures)

Any idea? Should I use the usual scenario with Route Guard or I should just have a separated panel (For example within an unknown directory)?


回答1:


You can secure backend API's with an admin token so any user who want to get/post/delete any critical data need a valid token that can let him access.

Never let your 'secret key' or any authentication decoding data in the front.

In node.js you can add an admin middlware that check if the user is an admin or not (after decoding the token sended from the front website).

check this article it might help.

nodejs securing api's



来源:https://stackoverflow.com/questions/56717180/angular-are-admin-files-downloadable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!