-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARO-9263: Add ACR token issue date and check validity #3778
ARO-9263: Add ACR token issue date and check validity #3778
Conversation
/azp run ci, e2e |
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
745f0ef
to
83b3a33
Compare
Please rebase pull request. |
4269f7e
to
a989623
Compare
83e35c5
to
29f8d05
Compare
Please rebase pull request. |
e22da94
to
c80d941
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple things to improve and a couple of nits. Overall good work!
if issueDate == nil { | ||
return mimo.TerminalError(errors.New("no issue date detected")) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't have an issue date we've probably got a token that will never expire. Shouldn't we remove it anyway?
return mimo.TerminalError(errors.New("no issue date detected")) | ||
} | ||
|
||
daysInterval := int32(now.Sub(issueDate.Time).Hours() / 24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we should just be making use of golang's inbuilt duration funcs for this. Something like this:
now := time.Now().UTC()
lastValidIssue := now.Sub(daysShouldRotate * time.Day)
lastValidRotation := now.Sub(daysValid * time.Day)
if issueDate.Time.Before(lastValidIssue) {
return mimo.TerminalError(fmt.Errorf("%d days have passed since azure container registry (acr) token was issued, please rotate the token now", daysInterval))
}
if issueDate.Time.Before(lastValidRotation) {
return mimo.TerminalError(fmt.Errorf("azure container registry (acr) token is not valid, %d days have passed", daysInterval))
}
29f8d05
to
f760cda
Compare
Please rebase pull request. |
…es detected by automated checks
1546e57
to
9a51858
Compare
Which issue this PR addresses:
Jira https://issues.redhat.com/browse/ARO-8472
https://issues.redhat.com/browse/ARO-9263
What this PR does / why we need it:
Test plan for issue:
Unit tests.
Manual validation.
Is there any documentation that needs to be updated for this PR?
Part of MIMO M1
How do you know this will function as expected in production?
Unit tests.