Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions api/internal/handler/consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ func (h *Handler) Create(c droplet.Context) (interface{}, error) {
}
input.ID = input.Username

if _, ok := input.Plugins["jwt-auth"]; ok {
jwt := input.Plugins["jwt-auth"].(map[string]interface{})
jwt["exp"] = 86400
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why add exp = 86400?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there is a problem with the default value setting of the current jsonschema, a temporary solution

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add issue for it


input.Plugins["jwt-auth"] = jwt
}

if err := h.consumerStore.Create(c.Context(), input); err != nil {
return handler.SpecCodeResponse(err), err
}
Expand All @@ -128,6 +135,13 @@ func (h *Handler) Update(c droplet.Context) (interface{}, error) {
}
input.Consumer.ID = input.Consumer.Username

if _, ok := input.Consumer.Plugins["jwt-auth"]; ok {
jwt := input.Consumer.Plugins["jwt-auth"].(map[string]interface{})
jwt["exp"] = 86400

input.Consumer.Plugins["jwt-auth"] = jwt
}

if err := h.consumerStore.Update(c.Context(), &input.Consumer, true); err != nil {
//if not exists, create
if err.Error() == fmt.Sprintf("key: %s is not found", input.Username) {
Expand Down