Skip to content

feat: Allow io.cozy.contacts and io.cozy.contacts.groups in token exc…#4745

Merged
shepilov merged 1 commit intomasterfrom
feat/add-contacts-in-token-exchange
May 5, 2026
Merged

feat: Allow io.cozy.contacts and io.cozy.contacts.groups in token exc…#4745
shepilov merged 1 commit intomasterfrom
feat/add-contacts-in-token-exchange

Conversation

@zatteo
Copy link
Copy Markdown
Member

@zatteo zatteo commented Apr 30, 2026

…hange

Replace the single allowed scope constant with an allowlist and a validateTokenExchangeScope function that accepts any space-separated combination of io.cozy.files, io.cozy.contacts, and io.cozy.contacts.groups.

@zatteo zatteo requested a review from a team as a code owner April 30, 2026 12:23
@zatteo zatteo force-pushed the feat/add-contacts-in-token-exchange branch 2 times, most recently from f37d590 to 8427d13 Compare May 4, 2026 06:11
}
if req.Scope != tokenExchangeAllowedScope {
return nil, echo.NewHTTPError(http.StatusBadRequest, "invalid scope")
if err := validateTokenExchangeScope(req.Scope); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please trim spaces before validation, and use stings.Split please, because later we use it, and with stings.Fields you allow tokens like io.cozy.files\tio.cozy.contact.

Or if you want a multiline support, you then need to use strings.Join(fields, " ") as scope, and return it from validation function, and then probably rename it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. I let you check again and merge if it's okay 👍

…hange

Replace the single allowed scope constant with an allowlist and a
validateTokenExchangeScope function that accepts any space-separated
combination of io.cozy.files, io.cozy.contacts, and
io.cozy.contacts.groups.
@zatteo zatteo force-pushed the feat/add-contacts-in-token-exchange branch from 8427d13 to 05f3b8a Compare May 4, 2026 08:39
@shepilov shepilov merged commit 63cfbea into master May 5, 2026
4 checks passed
@shepilov shepilov deleted the feat/add-contacts-in-token-exchange branch May 5, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants