fix(iam): make a rotation attempt survive a failure
key-rotation-controller / image (push) Failing after 19s
key-rotation-controller / image (push) Failing after 19s
Three defects, each seen in a live rotation of grafana:
scope the access token needs urn:zitadel:iam:org:project:id:zitadel:aud,
otherwise the management API answers 401 Token.Invalid even though the
assertion was accepted.
app id the objects carry the client id, and the secret endpoint takes the app
resource id. They differ, so every call answered 404 Application
doesn't exist. The correct ids are recorded per object.
attempt time record ActiveCredentialID and LastRotation right after Prepare. Without
it a later failure leaves LastRotation empty, the due check says rotate
now, and each reconcile mints a new secret and restarts the consumer:
grafana was rolled continuously and never became ready.
Also raise the consumer-ready budget to 8 minutes, because grafana needs about four,
and retry a failed attempt after 2 minutes instead of waiting a whole interval.
This commit is contained in:
@@ -63,7 +63,9 @@ func (c *Client) AccessToken() (string, error) {
|
||||
form := url.Values{}
|
||||
form.Set("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")
|
||||
form.Set("assertion", assertion)
|
||||
form.Set("scope", "openid")
|
||||
// The management API rejects a token without the ZITADEL project audience:
|
||||
// the request returns 401 Token.Invalid even though the assertion was accepted.
|
||||
form.Set("scope", "openid urn:zitadel:iam:org:project:id:zitadel:aud")
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, strings.TrimRight(c.cfg.Issuer, "/")+"/oauth/v2/token", strings.NewReader(form.Encode()))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user