IRIS 验证与授权
认证类型
HTTP Basic Auth
简单点说明就是每次请求时都提供用户用户名和密码,把用户名密码暴露给第三方客户端的风险,在生产环境下被使用的越来越少。 因此,在开发对外开放的时,尽量避免采用
OAUth2
OAuth
OAuthOAuth
Cookie+session
HTTP
SessionSessionSessionSession
IDIDCookieCookieCookie
JWT
JSON Web TokenJWTJWTJWT
HTTP BASIC认证
BASIC认证概述
HTTPHTTPHTTPWEBHTTPHTTPHTTPBASE64iris123456:BASE64Request HeaderHTTPBASE64
BASIC认证的过程
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: xxx
http1.01.1401
go Get /index.html HTTP/1.0 Host:www.studyiris.com Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxx //加密串
Authorization
BASIC认证缺点
HTTPdomainrealmBASE64HTTP
目录结构
basicauth
代码示例
main.go
main_test.go
提示
http://localhost:8080/adminexpirEnbaletrue