Repository: jcmturner/gokrb5
Pull request #134 (2018-06-10 14:50:14)

update to using goidentity version 2

jcmturner: resolves #133 

Patch:
diff --git a/README.md b/README.md
index f13ffc1..1dfa4f0 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 To get the package, execute:
 ```
 go get gopkg.in/jcmturner/gokrb5.v5
-go get gopkg.in/jcmturner/goidentity.v1
+go get gopkg.in/jcmturner/goidentity.v2
 go get gopkg.in/jcmturner/dnsutils.v1
 go get gopkg.in/jcmturner/aescts.v1
 go get github.com/hashicorp/go-uuid
diff --git a/credentials/credentials.go b/credentials/credentials.go
index c19b19a..b1b4755 100644
--- a/credentials/credentials.go
+++ b/credentials/credentials.go
@@ -105,9 +105,9 @@ func (c *Credentials) HasKeytab() bool {
 	return false
 }
 
-// SetValidUntil sets the TTL of the credentials
-func (c *Credentials) SetValidUntil(validUntil time.Time) {
-	c.ValidUntil = validUntil
+// SetValidUntil sets the expiry time of the credentials
+func (c *Credentials) SetValidUntil(t time.Time) {
+	c.ValidUntil = t
 }
 
 // HasPassword queries if the Credentials has a password defined.
@@ -247,3 +247,11 @@ func (c *Credentials) Authorized(a string) bool {
 func (c *Credentials) SessionID() string {
 	return c.sessionID
 }
+
+// Expired indicates if the credential has expired.
+func (c *Credentials) Expired() bool {
+	if !c.ValidUntil.IsZero() && time.Now().UTC().After(c.ValidUntil) {
+		return true
+	}
+	return false
+}
diff --git a/service/authenticator.go b/service/authenticator.go
index b2ef177..075c56e 100644
--- a/service/authenticator.go
+++ b/service/authenticator.go
@@ -7,7 +7,7 @@ import (
 	"strings"
 	"time"
 
-	goidentity "gopkg.in/jcmturner/goidentity.v1"
+	goidentity "gopkg.in/jcmturner/goidentity.v2"
 	"gopkg.in/jcmturner/gokrb5.v5/client"
 	"gopkg.in/jcmturner/gokrb5.v5/config"
 	"gopkg.in/jcmturner/gokrb5.v5/credentials"
@@ -15,7 +15,7 @@ import (
 	"gopkg.in/jcmturner/gokrb5.v5/keytab"
 )
 
-// SPNEGOAuthenticator implements gopkg.in/jcmturner/goidentity.v1.Authenticator interface
+// SPNEGOAuthenticator implements gopkg.in/jcmturner/goidentity.v2.Authenticator interface
 type SPNEGOAuthenticator struct {
 	SPNEGOHeaderValue string
 	Keytab            *keytab.Keytab
@@ -66,7 +66,7 @@ func (a SPNEGOAuthenticator) Mechanism() string {
 	return "SPNEGO Kerberos"
 }
 
-// KRB5BasicAuthenticator implements gopkg.in/jcmturner/goidentity.v1.Authenticator interface.
+// KRB5BasicAuthenticator implements gopkg.in/jcmturner/goidentity.v2.Authenticator interface.
 // It takes username and password so can be used for basic authentication.
 type KRB5BasicAuthenticator struct {
 	BasicHeaderValue string
diff --git a/service/http.go b/service/http.go
index cfa9fc7..9b14594 100644
--- a/service/http.go
+++ b/service/http.go
@@ -21,7 +21,7 @@ const (
 	spnegoNegTokenRespReject = "Negotiate oQcwBaADCgEC"
 	// CTXKeyAuthenticated is the request context key holding a boolean indicating if the request has been authenticated.
 	CTXKeyAuthenticated ctxKey = 0
-	// CTXKeyCredentials is the request context key holding the credentials gopkg.in/jcmturner/goidentity.v1/Identity object.
+	// CTXKeyCredentials is the request context key holding the credentials gopkg.in/jcmturner/goidentity.v2/Identity object.
 	CTXKeyCredentials ctxKey = 1
 )
 


Test patch:
diff --git a/credentials/credentials_test.go b/credentials/credentials_test.go
index 62bea4d..a7012cc 100644
--- a/credentials/credentials_test.go
+++ b/credentials/credentials_test.go
@@ -2,7 +2,7 @@ package credentials
 
 import (
 	"github.com/stretchr/testify/assert"
-	"gopkg.in/jcmturner/goidentity.v1"
+	goidentity "gopkg.in/jcmturner/goidentity.v2"
 	"testing"
 )
 
diff --git a/service/authenticator_test.go b/service/authenticator_test.go
index f065ef6..c349c7a 100644
--- a/service/authenticator_test.go
+++ b/service/authenticator_test.go
@@ -4,7 +4,7 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/assert"
-	"gopkg.in/jcmturner/goidentity.v1"
+	"gopkg.in/jcmturner/goidentity.v2"
 )
 
 func TestImplementsInterface(t *testing.T) {