Hi Jameel,
On Thu, Jan 28, 2016 at 4:55 AM, Jameel Al-Aziz <
m...@jalaziz.io> wrote:
> 1) "lookup-self" returns a different TTL than "renew-self" if the increment
> is different than the original TTL. It seems that the new TTL is not stored
> in the token store and is only used to update the expiration.
That's correct. The TTL output is the one stored at token creation
time, which is what was set when the token was created. As of a month
ago we now look up the lease times in the expiration manager in order
to set last_renewal_time, so it's possible we could change the meaning
of TTL, but that would be a breaking API change. Instead, maybe we can
simply add another field -- so there is TTL which is static, and there
is expiration which is the actual time that the lease will expire,
taking into account any renewals. Feel free to file an issue about
this.
> 2) Since the "GracePeriod" is only set at token create time, renewing will
> cause expiraion after Increment + original Grace Period seconds. For
> example, if a token is created with a TTL of 1h (3600s) and immediately
> renewed with a TTL of 1m (60s), the token will expire after 420 seconds.
Honestly, I'm not a fan of the grace period because it leads to
confusion like this, and I plan to rip it out as soon as I can, except
that that won't be until we can make a breaking API change :-/
That's a good catch, although the root of this has been going on a bit
before that particular commit. Here's an in-depth explanation:
The original blunt-force approach of a hard-coded 30 day maximum token
time was very hard for a lot of organizations to deal with, so in 0.3
we introduced both system-wide default/max TTL and specific mount
tuning with two initial options -- default lease TTL and max lease
TTL. The default is up to the individual backends to honor...and many
don't, but we're doing planning for v2 of the backend framework which
will generally take these kinds of decisions away from individual
backends so that they have much more consistent UX. The max lease TTL
is *always* enforced, because enforcement happens in the core.
This makes for a much more flexible approach, because you can have
multiple mounts of each backend, so you can enforce different maximums
regardless of how the backend itself behaves (and eventually,
defaults), plus you can selectively override the system default/max.
Renewability was always keyed to whether the TTL was greater than
zero; it's just that now there is always a default of one type or
another, either at the system side or the mount side, so you basically
never have a TTL of zero. This leads to the situation you found.
This isn't really a *problem* -- at least not in any security sense --
since you could never go past your maximum lease TTL even with
renewing. So having a non-renewable token of TTL X is essentially the
same as having a renewable token with a maximum TTL of X.
The longer term fix for this is that as we work on enhancing the
backend framework we're going to be expanding the options exposed by
mount-tune. For instance, one idea is to strip MFA support out of a
specific backend itself and instead bring that into core (e.g.
configured via /sys) so that you can then use a mount tuning option to
determine which defined MFAs are available/should be used by any given
mount -- suddenly *any* mount can use MFA, not just ones that are
specifically coded to be compatible with it. Along with this expansion
in mount tuning options I've been planning to add renewability as a
toggleable option, so rather than keyed to TTL > 0, it's just a
boolean that is set on that mount, or not.
We're still figuring out the details of how much overriding a
particular role within a backend should have over these set options.
But allowing overrides can lead right back to the current situation of
a lot of copy and pasted code between backends that never quite works
the same, and that's what we want to get rid of in the first place, so
we may just have these options live as mount tunables, and for
different needs a different copy of the backend can be mounted.
Let me know if that all makes sense to you...
--Jeff