BasicAuthForRealm() — gin Function Reference
Architecture documentation for the BasicAuthForRealm() function in auth.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 9c86e2a9_4c6a_8db8_8685_d4c53bd42628["BasicAuthForRealm()"] 23f4895f_9ece_2655_5ad3_248aaf5dbcc5["BasicAuth()"] 23f4895f_9ece_2655_5ad3_248aaf5dbcc5 -->|calls| 9c86e2a9_4c6a_8db8_8685_d4c53bd42628 1f4b5bde_c3a6_93bc_e638_e4941f48fd50["processAccounts()"] 9c86e2a9_4c6a_8db8_8685_d4c53bd42628 -->|calls| 1f4b5bde_c3a6_93bc_e638_e4941f48fd50 12c00ed5_b5c2_0171_2729_3ff6e12efb0f["searchCredential()"] 9c86e2a9_4c6a_8db8_8685_d4c53bd42628 -->|calls| 12c00ed5_b5c2_0171_2729_3ff6e12efb0f style 9c86e2a9_4c6a_8db8_8685_d4c53bd42628 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
Called By
Source
Frequently Asked Questions
What does BasicAuthForRealm() do?
BasicAuthForRealm() is a function in the gin codebase.
What does BasicAuthForRealm() call?
BasicAuthForRealm() calls 2 function(s): processAccounts, searchCredential.
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