mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Merge pull request #73409 from yue9944882/bugfix/compatible-with-nil-authorizer
Fixes authz compatibility w/ nil authorizer in apiserver
This commit is contained in:
		@@ -614,9 +614,18 @@ func (s *SecureServingInfo) HostPort() (string, int, error) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// AuthorizeClientBearerToken wraps the authenticator and authorizer in loopback authentication logic
 | 
					// AuthorizeClientBearerToken wraps the authenticator and authorizer in loopback authentication logic
 | 
				
			||||||
// if the loopback client config is specified AND it has a bearer token.
 | 
					// if the loopback client config is specified AND it has a bearer token. Note that if either authn or
 | 
				
			||||||
 | 
					// authz is nil, this function won't add a token authenticator or authorizer.
 | 
				
			||||||
func AuthorizeClientBearerToken(loopback *restclient.Config, authn *AuthenticationInfo, authz *AuthorizationInfo) {
 | 
					func AuthorizeClientBearerToken(loopback *restclient.Config, authn *AuthenticationInfo, authz *AuthorizationInfo) {
 | 
				
			||||||
	if loopback == nil || authn == nil || authz == nil || authn.Authenticator == nil && authz.Authorizer == nil || len(loopback.BearerToken) == 0 {
 | 
						if loopback == nil || len(loopback.BearerToken) == 0 {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if authn == nil || authz == nil {
 | 
				
			||||||
 | 
							// prevent nil pointer panic
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if authn.Authenticator == nil || authz.Authorizer == nil {
 | 
				
			||||||
 | 
							// authenticator or authorizer might be nil if we want to bypass authz/authn
 | 
				
			||||||
 | 
							// and we also do nothing in this case.
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user