Jonathan Turner 8 лет назад
Родитель
Сommit
5e010c072d

+ 1 - 1
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

+ 10 - 3
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,10 @@ func (c *Credentials) Authorized(a string) bool {
 func (c *Credentials) SessionID() string {
 	return c.sessionID
 }
+
+func (c *Credentials) Expired() bool {
+	if !c.ValidUntil.IsZero() && time.Now().UTC().After(c.ValidUntil) {
+		return true
+	}
+	return false
+}

+ 1 - 1
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"
 )
 

+ 3 - 3
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

+ 1 - 1
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) {

+ 1 - 1
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
 )