-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: Add keep pairs option for keys deletion #1570
Conversation
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.
Awesome! A couple of changes :)
jwk/handler.go
Outdated
|
||
if err := h.r.KeyManager().DeleteKeySet(r.Context(), setName); err != nil { | ||
if olderThan != "" { | ||
date, err := time.Parse("2006-01-02", olderThan) |
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.
Would a unix timestamp make more sense here? Because here we don't know about timezones etc.
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.
Sounds better! I fixed it!
jwk/handler.go
Outdated
@@ -327,8 +328,22 @@ func (h *Handler) UpdateKey(w http.ResponseWriter, r *http.Request, ps httproute | |||
// 500: genericError | |||
func (h *Handler) DeleteKeySet(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { | |||
var setName = ps.ByName("set") | |||
var olderThan = r.URL.Query().Get("older-than") |
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.
This should be documented in swagger :)
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.
Also maybe rename this to before
?
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.
Yes, I added the param to jwk/docs.go
}) | ||
|
||
t.Run("DeleteJSONWebKeySet", func(t *testing.T) { | ||
deleteJWKSetPath := "/keys/test-key" |
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.
The older-than/before feature should be tested here!
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.
Sure! I will add a test case :)
jwk/manager_sql.go
Outdated
@@ -211,6 +211,13 @@ func (m *SQLManager) DeleteKey(ctx context.Context, set, kid string) error { | |||
return nil | |||
} | |||
|
|||
func (m *SQLManager) DeleteOldKeys(ctx context.Context, set string, date time.Time) error { |
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.
The manager_test should have a test for this method
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.
This is also I will do it!
Let me know when this is good for another review :) |
9cd7cd6
to
3b46649
Compare
@aeneasr I have done! Could you review again? |
Signed-off-by: Shota Sawada <xiootas@gmail.com>
Signed-off-by: Shota Sawada <xiootas@gmail.com>
Signed-off-by: Shota Sawada <xiootas@gmail.com>
Signed-off-by: Shota Sawada <xiootas@gmail.com>
Signed-off-by: Shota Sawada <xiootas@gmail.com>
288a501
to
f697aac
Compare
Signed-off-by: Shota Sawada <shota@sslife.tech>
Signed-off-by: Shota Sawada <shota@sslife.tech>
f697aac
to
00a4bab
Compare
I couldn't generate SDK before but I get to do it now! @aeneasr I'm so sorry to be late. Can you review again? |
Closing due to inactivity - would probably need another overhaul to address this as we've changed quite a lot internally in the meanwhile. |
Related issue
This PR will closes #1476
Proposed changes
Checklist
vulnerability, I confirm that I got green light (please contact security@ory.sh) from the maintainers to push the changes.
Further comments