mirror of
				https://github.com/vbatts/srvdav.git
				synced 2025-10-27 02:46:42 +00:00 
			
		
		
		
	vendor: dep init
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
		
							parent
							
								
									83a1e114b0
								
							
						
					
					
						commit
						6feae25207
					
				
					 945 changed files with 238318 additions and 0 deletions
				
			
		
							
								
								
									
										35
									
								
								vendor/github.com/abbot/go-http-auth/examples/basic.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								vendor/github.com/abbot/go-http-auth/examples/basic.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| // +build ignore | ||||
| 
 | ||||
| /* | ||||
|  Example application using Basic auth | ||||
| 
 | ||||
|  Build with: | ||||
| 
 | ||||
|  go build basic.go | ||||
| */ | ||||
| 
 | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	auth ".." | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| ) | ||||
| 
 | ||||
| func Secret(user, realm string) string { | ||||
| 	if user == "john" { | ||||
| 		// password is "hello" | ||||
| 		return "$1$dlPL2MqE$oQmn16q49SqdmhenQuNgs1" | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| 
 | ||||
| func handle(w http.ResponseWriter, r *auth.AuthenticatedRequest) { | ||||
| 	fmt.Fprintf(w, "<html><body><h1>Hello, %s!</h1></body></html>", r.Username) | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	authenticator := auth.NewBasicAuthenticator("example.com", Secret) | ||||
| 	http.HandleFunc("/", authenticator.Wrap(handle)) | ||||
| 	http.ListenAndServe(":8080", nil) | ||||
| } | ||||
							
								
								
									
										60
									
								
								vendor/github.com/abbot/go-http-auth/examples/context.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								vendor/github.com/abbot/go-http-auth/examples/context.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,60 @@ | |||
| // +build ignore | ||||
| 
 | ||||
| /* | ||||
|  Example application using NewContext/FromContext | ||||
| 
 | ||||
|  Build with: | ||||
| 
 | ||||
|  go build context.go | ||||
| */ | ||||
| 
 | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 
 | ||||
| 	auth ".." | ||||
| 	"golang.org/x/net/context" | ||||
| ) | ||||
| 
 | ||||
| func Secret(user, realm string) string { | ||||
| 	if user == "john" { | ||||
| 		// password is "hello" | ||||
| 		return "b98e16cbc3d01734b264adba7baa3bf9" | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| 
 | ||||
| type ContextHandler interface { | ||||
| 	ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) | ||||
| } | ||||
| 
 | ||||
| type ContextHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http.Request) | ||||
| 
 | ||||
| func (f ContextHandlerFunc) ServeHTTP(ctx context.Context, w http.ResponseWriter, r *http.Request) { | ||||
| 	f(ctx, w, r) | ||||
| } | ||||
| 
 | ||||
| func handle(ctx context.Context, w http.ResponseWriter, r *http.Request) { | ||||
| 	authInfo := auth.FromContext(ctx) | ||||
| 	authInfo.UpdateHeaders(w.Header()) | ||||
| 	if authInfo == nil || !authInfo.Authenticated { | ||||
| 		http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) | ||||
| 		return | ||||
| 	} | ||||
| 	fmt.Fprintf(w, "<html><body><h1>Hello, %s!</h1></body></html>", authInfo.Username) | ||||
| } | ||||
| 
 | ||||
| func authenticatedHandler(a auth.AuthenticatorInterface, h ContextHandler) http.Handler { | ||||
| 	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||
| 		ctx := a.NewContext(context.Background(), r) | ||||
| 		h.ServeHTTP(ctx, w, r) | ||||
| 	}) | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	authenticator := auth.NewDigestAuthenticator("example.com", Secret) | ||||
| 	http.Handle("/", authenticatedHandler(authenticator, ContextHandlerFunc(handle))) | ||||
| 	http.ListenAndServe(":8080", nil) | ||||
| } | ||||
							
								
								
									
										35
									
								
								vendor/github.com/abbot/go-http-auth/examples/digest.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								vendor/github.com/abbot/go-http-auth/examples/digest.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | |||
| // +build ignore | ||||
| 
 | ||||
| /* | ||||
|  Example application using Digest auth | ||||
| 
 | ||||
|  Build with: | ||||
| 
 | ||||
|  go build digest.go | ||||
| */ | ||||
| 
 | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	auth ".." | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| ) | ||||
| 
 | ||||
| func Secret(user, realm string) string { | ||||
| 	if user == "john" { | ||||
| 		// password is "hello" | ||||
| 		return "b98e16cbc3d01734b264adba7baa3bf9" | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| 
 | ||||
| func handle(w http.ResponseWriter, r *auth.AuthenticatedRequest) { | ||||
| 	fmt.Fprintf(w, "<html><body><h1>Hello, %s!</h1></body></html>", r.Username) | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	authenticator := auth.NewDigestAuthenticator("example.com", Secret) | ||||
| 	http.HandleFunc("/", authenticator.Wrap(handle)) | ||||
| 	http.ListenAndServe(":8080", nil) | ||||
| } | ||||
							
								
								
									
										36
									
								
								vendor/github.com/abbot/go-http-auth/examples/wrapped.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								vendor/github.com/abbot/go-http-auth/examples/wrapped.go
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,36 @@ | |||
| // +build ignore | ||||
| 
 | ||||
| /* | ||||
|  Example demonstrating how to wrap an application which is unaware of | ||||
|  authenticated requests with a "pass-through" authentication | ||||
| 
 | ||||
|  Build with: | ||||
| 
 | ||||
|  go build wrapped.go | ||||
| */ | ||||
| 
 | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	auth ".." | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| ) | ||||
| 
 | ||||
| func Secret(user, realm string) string { | ||||
| 	if user == "john" { | ||||
| 		// password is "hello" | ||||
| 		return "$1$dlPL2MqE$oQmn16q49SqdmhenQuNgs1" | ||||
| 	} | ||||
| 	return "" | ||||
| } | ||||
| 
 | ||||
| func regular_handler(w http.ResponseWriter, r *http.Request) { | ||||
| 	fmt.Fprintf(w, "<html><body><h1>This application is unaware of authentication</h1></body></html>") | ||||
| } | ||||
| 
 | ||||
| func main() { | ||||
| 	authenticator := auth.NewBasicAuthenticator("example.com", Secret) | ||||
| 	http.HandleFunc("/", auth.JustCheck(authenticator, regular_handler)) | ||||
| 	http.ListenAndServe(":8080", nil) | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue