Home / Function/ BasicAuthForProxy() — gin Function Reference

BasicAuthForProxy() — gin Function Reference

Architecture documentation for the BasicAuthForProxy() function in auth.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  30980521_1bd7_5c49_80b3_a997ebd13429["BasicAuthForProxy()"]
  1f4b5bde_c3a6_93bc_e638_e4941f48fd50["processAccounts()"]
  30980521_1bd7_5c49_80b3_a997ebd13429 -->|calls| 1f4b5bde_c3a6_93bc_e638_e4941f48fd50
  12c00ed5_b5c2_0171_2729_3ff6e12efb0f["searchCredential()"]
  30980521_1bd7_5c49_80b3_a997ebd13429 -->|calls| 12c00ed5_b5c2_0171_2729_3ff6e12efb0f
  style 30980521_1bd7_5c49_80b3_a997ebd13429 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

auth.go lines 98–116

func BasicAuthForProxy(accounts Accounts, realm string) HandlerFunc {
	if realm == "" {
		realm = "Proxy Authorization Required"
	}
	realm = "Basic realm=" + strconv.Quote(realm)
	pairs := processAccounts(accounts)
	return func(c *Context) {
		proxyUser, found := pairs.searchCredential(c.requestHeader("Proxy-Authorization"))
		if !found {
			// Credentials doesn't match, we return 407 and abort handlers chain.
			c.Header("Proxy-Authenticate", realm)
			c.AbortWithStatus(http.StatusProxyAuthRequired)
			return
		}
		// The proxy_user credentials was found, set proxy_user's id to key AuthProxyUserKey in this context, the proxy_user's id can be read later using
		// c.MustGet(gin.AuthProxyUserKey).
		c.Set(AuthProxyUserKey, proxyUser)
	}
}

Domain

Subdomains

Frequently Asked Questions

What does BasicAuthForProxy() do?
BasicAuthForProxy() is a function in the gin codebase.
What does BasicAuthForProxy() call?
BasicAuthForProxy() calls 2 function(s): processAccounts, searchCredential.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free