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
  9ae4877d_7d4f_acb7_dc57_6956d16a3624["BasicAuthForProxy()"]
  ec648c85_14aa_c807_9845_0e4df8dd602c["auth.go"]
  9ae4877d_7d4f_acb7_dc57_6956d16a3624 -->|defined in| ec648c85_14aa_c807_9845_0e4df8dd602c
  6711bab1_166d_3c3f_7ec8_eb9372536ad7["processAccounts()"]
  9ae4877d_7d4f_acb7_dc57_6956d16a3624 -->|calls| 6711bab1_166d_3c3f_7ec8_eb9372536ad7
  style 9ae4877d_7d4f_acb7_dc57_6956d16a3624 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

Defined In

Frequently Asked Questions

What does BasicAuthForProxy() do?
BasicAuthForProxy() is a function in the gin codebase, defined in auth.go.
Where is BasicAuthForProxy() defined?
BasicAuthForProxy() is defined in auth.go at line 98.
What does BasicAuthForProxy() call?
BasicAuthForProxy() calls 1 function(s): processAccounts.

Analyze Your Own Codebase

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

Try Supermodel Free