Set WWW-Authenticate header directly and change realm to spaceapid for consistency
This commit is contained in:
		
					parent
					
						
							
								bc299d4c70
							
						
					
				
			
			
				commit
				
					
						fa6e6bd142
					
				
			
		
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -19,7 +19,7 @@ func updateEndpointValidator(
 | 
				
			||||||
	// Check BasicAuth credentials
 | 
						// Check BasicAuth credentials
 | 
				
			||||||
	username, password, ok := r.BasicAuth()
 | 
						username, password, ok := r.BasicAuth()
 | 
				
			||||||
	if !ok || !util.CheckCredentials(authDB, validCredentials, username, password) {
 | 
						if !ok || !util.CheckCredentials(authDB, validCredentials, username, password) {
 | 
				
			||||||
		w.Header().Set("WWW-Authenticate", "Basic realm=\"space-api\"")
 | 
							w.Header()["WWW-Authenticate"] = []string{"Basic realm=\"spaceapid\""}
 | 
				
			||||||
		http.Error(w, "", http.StatusUnauthorized)
 | 
							http.Error(w, "", http.StatusUnauthorized)
 | 
				
			||||||
		return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password))
 | 
							return []byte{}, errors.New(fmt.Sprintf("Unauthorized request from %s Username: %s Password: %s", r.RemoteAddr, username, password))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue