IRIS 验证与授权
认证类型
HTTP Basic Auth简单点说明就是每次请求时都提供用户用户名和密码,把用户名密码暴露给第三方客户端的风险,在生产环境下被使用的越来越少。 因此,在开发对外开放的时,尽量避免采用OAUth2OAuthOAuthOAuthCookie+sessionHTTPSessionSessionSessionSessionIDIDCookieCookieCookieJWTJSON Web TokenJWTJWTJWTHTTP BASIC认证
BASIC认证概述
HTTPHTTPHTTPWEBHTTPHTTPHTTPBASE64iris123456:BASE64Request HeaderHTTPBASE64BASIC认证的过程
MIME```go Get /index.html HTTP/1.0
```
- 服务器向客户端发送验证请求代码401,服务器返回的数据:
go HTTP/1.0 401 Unauthorised Server: nginx/1.0 WWW-Authenticate: Basic realm="studyiris.com" Content-Type: text/html Content-Length: xxxhttp1.01.1401go Get /index.html HTTP/1.0 Host:www.studyiris.com Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxx //加密串AuthorizationBASIC认证缺点
HTTPdomainrealmBASE64HTTP目录结构
basicauth代码示例
main.gomain_test.go提示
http://localhost:8080/adminexpirEnbaletrue