Explorar o código

refine spnego client method

Jonathan Turner %!s(int64=9) %!d(string=hai) anos
pai
achega
4020cb33bc
Modificáronse 3 ficheiros con 4 adicións e 4 borrados
  1. 1 1
      README.md
  2. 2 2
      client/http.go
  3. 1 1
      debug.go

+ 1 - 1
README.md

@@ -67,7 +67,7 @@ tkt, err := cl.GetServiceTicket("HTTP/host.test.gokrb5")
 Create the HTTP request object and then call the client's SetSPNEGOHeader method passing the Service Principal Name (SPN)
 Create the HTTP request object and then call the client's SetSPNEGOHeader method passing the Service Principal Name (SPN)
 ```go
 ```go
 r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
 r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
-cl.SetSPNEGOHeader(r, "HTTP/host.test.gokrb5")
+cl.SetSPNEGOHeader(r)
 HTTPResp, err := http.DefaultClient.Do(r)
 HTTPResp, err := http.DefaultClient.Do(r)
 ```
 ```
 
 

+ 2 - 2
client/http.go

@@ -7,8 +7,8 @@ import (
 	"net/http"
 	"net/http"
 )
 )
 
 
-func (cl *Client) SetSPNEGOHeader(HTTPReq *http.Request, spn string) error {
-	tkt, skey, err := cl.GetServiceTicket(spn)
+func (cl *Client) SetSPNEGOHeader(HTTPReq *http.Request) error {
+	tkt, skey, err := cl.GetServiceTicket("HTTP/" + HTTPReq.Host)
 	if err != nil {
 	if err != nil {
 		return fmt.Errorf("Could not get service ticket: %v", err)
 		return fmt.Errorf("Could not get service ticket: %v", err)
 	}
 	}

+ 1 - 1
debug.go

@@ -73,7 +73,7 @@ func httpRequest() {
 		fmt.Fprintf(os.Stderr, "Error on AS_REQ: %v\n", err)
 		fmt.Fprintf(os.Stderr, "Error on AS_REQ: %v\n", err)
 	}
 	}
 	r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
 	r, _ := http.NewRequest("GET", "http://host.test.gokrb5/index.html", nil)
-	cl.SetSPNEGOHeader(r, "HTTP/host.test.gokrb5")
+	cl.SetSPNEGOHeader(r)
 	httpResp, err := http.DefaultClient.Do(r)
 	httpResp, err := http.DefaultClient.Do(r)
 	fmt.Fprintf(os.Stderr, "RESPONSE CODE: %v\n", httpResp.StatusCode)
 	fmt.Fprintf(os.Stderr, "RESPONSE CODE: %v\n", httpResp.StatusCode)
 }
 }