Learning Day 9 of Building Distributed Applications with the Gin Framework, p127-p142 Summary, 16 pages total.
I. Technical summary
Summary of modalities
(1)API keys
Example of API keys authentication method:
func (handler *RecipesHandler) NewRecipeHandler(c *) {
// API-keys accreditation
value := ("X-API-KEY")
("X-API-KEY in env: ", value)
if value == "" {
value = "codists"
}
("X-API-KEY in header:", ("X-API-KEY"))
if ("X-API-KEY") != value {
(, {"message": "Unauthorized"})
return
}
// Deserialization of request parameters
var recipe
if err := (&recipe); err != nil {
(, {"error": ()})
}
insertionResult, err := (, &{})
if err != nil {
// Failed to add,Returns an error to the front end
(, {"message": "Failed to add" + ()})
return
}
("Remove recipes from Redis")
(, "recipes")
// Added successfully,come (or go) back ID
(, )
}
I have not encountered this approach in my actual work experience, but I have seen it in practice on other sites.
(2)Basic Auth
(3)Client session
(4)OpenID Connect
(5)OpenAutherization(OAuth) 2.0
A description of JWT can be found in RFC 7519:/doc/html/rfc7519. The author of the book used the package jwt-go, which is now archived, and people turn to golang-jwt.
point of knowledge (math.)
(1)()
II. English summary
up
p133,API keys are simple; however, anyone who makes a request to an API transmits their key,and in theory, the key can be picked up easily with a man-in-the-middle (MITM) attack
when no encryption is in use.
vt. to get sth. The word pick up is very flexible in its usage and feels like it can be used in many scenarios.
p134, A JWT token consists of three parts separated by dots, as depicted in the following
screenshot...
(1)depict: de-("down") + pingere("to paint")。vt. to represent or show sth in a picture(depict).
III. Other
Although you have used JWT when working with Python and Flask, this chapter is still a slow read, the essence of which lies in unfamiliarity with the Go language and the frameworks used in Go development.
IV. References
1. Programming
(1) Mohamed Labouardy,《Building Distributed Applications in Gin》:/subject/35610349
2. English
(1) Etymology Dictionary:
(2) Cambridge Dictionary:
Welcome to search and follow: programmers (a_codists)