mirror of
https://github.com/smallstep/certificates.git
synced 2024-10-31 03:20:16 +00:00
Fix backward compatibility in AuthorizeAdminToken
This commit validates both new and old issuers.
This commit is contained in:
parent
5f714f2485
commit
ad5aedfa60
@ -130,7 +130,6 @@ func (a *Authority) AuthorizeAdminToken(r *http.Request, token string) (*linkedc
|
||||
// According to "rfc7519 JSON Web Token" acceptable skew should be no
|
||||
// more than a few minutes.
|
||||
if err := claims.ValidateWithLeeway(jose.Expected{
|
||||
Issuer: "step-admin-client/1.0",
|
||||
Time: time.Now().UTC(),
|
||||
}, time.Minute); err != nil {
|
||||
return nil, admin.WrapError(admin.ErrorUnauthorizedType, err, "x5c.authorizeToken; invalid x5c claims")
|
||||
@ -141,6 +140,12 @@ func (a *Authority) AuthorizeAdminToken(r *http.Request, token string) (*linkedc
|
||||
return nil, admin.NewError(admin.ErrorUnauthorizedType, "x5c.authorizeToken; x5c token has invalid audience claim (aud)")
|
||||
}
|
||||
|
||||
// validate issuer: old versions used the provisioner name, new version uses
|
||||
// 'step-admin-client/1.0'
|
||||
if claims.Issuer != "step-admin-client/1.0" && claims.Issuer != prov.GetName() {
|
||||
return nil, admin.NewError(admin.ErrorUnauthorizedType, "x5c.authorizeToken; x5c token has invalid issuer claim (iss)")
|
||||
}
|
||||
|
||||
if claims.Subject == "" {
|
||||
return nil, admin.NewError(admin.ErrorUnauthorizedType, "x5c.authorizeToken; x5c token subject cannot be empty")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user