BasicAuthForRealm() — gin Function Reference
Architecture documentation for the BasicAuthForRealm() function in auth.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 1d567119_4313_ef47_c187_f8c6992c85a8["BasicAuthForRealm()"] ec648c85_14aa_c807_9845_0e4df8dd602c["auth.go"] 1d567119_4313_ef47_c187_f8c6992c85a8 -->|defined in| ec648c85_14aa_c807_9845_0e4df8dd602c 44a9c3ac_96e6_8aff_b335_890eaf667f1c["BasicAuth()"] 44a9c3ac_96e6_8aff_b335_890eaf667f1c -->|calls| 1d567119_4313_ef47_c187_f8c6992c85a8 6711bab1_166d_3c3f_7ec8_eb9372536ad7["processAccounts()"] 1d567119_4313_ef47_c187_f8c6992c85a8 -->|calls| 6711bab1_166d_3c3f_7ec8_eb9372536ad7 style 1d567119_4313_ef47_c187_f8c6992c85a8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
auth.go lines 48–68
func BasicAuthForRealm(accounts Accounts, realm string) HandlerFunc {
if realm == "" {
realm = "Authorization Required"
}
realm = "Basic realm=" + strconv.Quote(realm)
pairs := processAccounts(accounts)
return func(c *Context) {
// Search user in the slice of allowed credentials
user, found := pairs.searchCredential(c.requestHeader("Authorization"))
if !found {
// Credentials doesn't match, we return 401 and abort handlers chain.
c.Header("WWW-Authenticate", realm)
c.AbortWithStatus(http.StatusUnauthorized)
return
}
// The user credentials was found, set user's id to key AuthUserKey in this context, the user's id can be read later using
// c.MustGet(gin.AuthUserKey).
c.Set(AuthUserKey, user)
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does BasicAuthForRealm() do?
BasicAuthForRealm() is a function in the gin codebase, defined in auth.go.
Where is BasicAuthForRealm() defined?
BasicAuthForRealm() is defined in auth.go at line 48.
What does BasicAuthForRealm() call?
BasicAuthForRealm() calls 1 function(s): processAccounts.
What calls BasicAuthForRealm()?
BasicAuthForRealm() is called by 1 function(s): BasicAuth.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free