我一直在使用API,我一直想知道为什么你必须使用密钥和秘密?
为什么需要两种类型的身份验证?
我正在使用 Spring、Spring Security 编写 Web 应用程序(REST API)。现在我有基本身份验证和使用用户名、密码和角色的非常简单的授权。我想改进安全层,但我没有这方面的经验。
当我查看邮递员寻找可能的身份验证方法并在谷歌上搜索时,我看到有以下选项:
Digest、Hawk、AWS 和 NTLM 似乎是非常具体的案例,所以我省略了它们。
我只听说过一些关于 API 密钥、不记名令牌和 OAuth 1.0\2.0 的一般信息,但 OAuth 1.0 似乎已经过时了或其他什么(我的意思是,2.0 版存在是有原因的)。
因此,我似乎有 3 种可能的变体:
我的假设正确吗?现代 Web 应用程序中最广泛使用的安全层案例是什么?
我不要求每个案例的完整描述,只是一般性建议,也许需要一些链接\资源来查看。
我应该专注于什么?
你看到我的描述\解释中有哪些错误?
security rest web-services restful-authentication spring-security
我想将"account"参数应用于所有路径,没有任何例外.有没有办法用Swagger 2做这个(我不想为每个路径应用"account"参数)?
{
"swagger": "2.0",
"info": {
"version": "1.0",
"title": "Doc"
},
"host": "localhost",
"schemes": [
"http"
],
"produces": [
"application/json"
],
"parameters": {
"account": {
"in": "header",
"name": "X-ACCOUNT",
"description": "Account id",
"type": "string",
"required": true
}
},
"paths": {
"/account": {
"get": {
"summary": "Get account",
"operationId": "getAccount",
"responses": {
"200": {
"description": "test"
}
}
}
},
..... other paths
}
}
Run Code Online (Sandbox Code Playgroud)