Skip to content

Commit

Permalink
internal/token: tokens are not renewable
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maldridge committed Aug 17, 2019
1 parent a6b27dc commit ad28706
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion cmd/netauthd/main.go
Expand Up @@ -53,7 +53,6 @@ func init() {

pflag.String("token.backend", "jwt-rsa", "Token implementation to use")
pflag.Duration("token.lifetime", time.Hour*10, "Token lifetime")
pflag.Int("token.renewals", 5, "Maximum number of times the token may be renewed")

pflag.Int("token.jwt.bits", 2048, "Bit length of generated keys")
pflag.Bool("token.jwt.generate", false, "Generate keys if not available")
Expand Down
1 change: 0 additions & 1 deletion internal/token/claims.go
Expand Up @@ -6,7 +6,6 @@ package token
type Claims struct {
EntityID string
Capabilities []string
RenewalsLeft int
}

// HasCapability is a convenience function to determine if the
Expand Down
1 change: 0 additions & 1 deletion internal/token/jwt/rsa.go
Expand Up @@ -58,7 +58,6 @@ func (s *RSATokenService) Generate(claims token.Claims, config token.Config) (st
return "", token.ErrKeyUnavailable
}

claims.RenewalsLeft = config.Renewals
c := RSAToken{
claims,
jwt.StandardClaims{
Expand Down
3 changes: 0 additions & 3 deletions internal/token/jwt/rsa_test.go
Expand Up @@ -21,7 +21,6 @@ import (
var (
config = token.Config{
Lifetime: time.Minute * 5,
Renewals: 0,
Issuer: "NetAuth Test",
}
)
Expand Down Expand Up @@ -169,7 +168,6 @@ func TestValidateToken(t *testing.T) {
Lifetime: time.Minute * 5,
IssuedAt: time.Now(),
NotBefore: time.Now(),
Renewals: 0,
Issuer: "NetAuth Test",
}

Expand Down Expand Up @@ -285,7 +283,6 @@ func TestValidateExpiredToken(t *testing.T) {
Lifetime: 0,
IssuedAt: time.Now().Add(-1 * time.Minute),
NotBefore: time.Now().Add(-1 * time.Minute),
Renewals: 0,
Issuer: "NetAuth Test",
}

Expand Down
2 changes: 0 additions & 2 deletions internal/token/token.go
Expand Up @@ -22,7 +22,6 @@ type Service interface {
// generating a token.
type Config struct {
Lifetime time.Duration
Renewals int
Issuer string
IssuedAt time.Time
NotBefore time.Time
Expand Down Expand Up @@ -78,7 +77,6 @@ func GetBackendList() []string {
func GetConfig() Config {
return Config{
Lifetime: viper.GetDuration("token.lifetime"),
Renewals: viper.GetInt("token.renewals"),
IssuedAt: time.Now(),
NotBefore: time.Now(),
}
Expand Down
2 changes: 1 addition & 1 deletion internal/token/token_test.go
Expand Up @@ -70,7 +70,7 @@ func TestNewUnknown(t *testing.T) {

func TestGetConfig(t *testing.T) {
c := GetConfig()
if c.Lifetime != viper.GetDuration("token.lifetime") || c.Renewals != viper.GetInt("token.renewals") {
if c.Lifetime != viper.GetDuration("token.lifetime") {
t.Error("Config contains incorrect values")
}
}

0 comments on commit ad28706

Please sign in to comment.