【发布时间】:2021-02-16 23:08:03
【问题描述】:
所以在我们的项目中,我负责 Angular 8 中的 UI 部分,后端使用 JAVA 开发。两者都将部署在同一个 Windows 服务器中。 目前,我们正在使用基本身份验证来验证用户身份并访问不同的 REST URL。我是新手,所以我对 JWT 令牌不太了解。 那么谁能解释一下使用基本身份验证和 JWT 令牌有什么区别?当后端和前端部署在同一台服务器上时,我们是否需要 JWT 令牌?
当前项目中使用基本身份验证的用户验证示例代码...
LoginAuthorisation(logindata: LoginData) {
let authrizationdata = logindata.inputEmail+":"+logindata.inputPassword;
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(authrizationdata),
}),
observe: "response" as const,
withCredentials: true
};
const body = { "message": "Test Data"}
console.log(httpOptions);
return this.http.post<any>('http://*****************/home',body,httpOptions);
}
【问题讨论】:
标签: java angular oauth-2.0 jwt basic-authentication