Skip to content
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

Updated audience validation for admin api tokens #10519

Merged
merged 5 commits into from Feb 23, 2019

Conversation

allouis
Copy link
Contributor

@allouis allouis commented Feb 23, 2019

no-issue

This is a temporary solution until we implement token permissions based on actions upon objects, for example using canThis

no-issue

This is a temporary solution until we implement token permissions based on actions upon objects, for example using canThis
@allouis allouis changed the title Removed audience validation for admin api tokens Updated audience validation for admin api tokens Feb 23, 2019
@allouis allouis merged commit 4a1a245 into master Feb 23, 2019
@allouis allouis deleted the remove-admin-api-audience-validation branch February 23, 2019 11:51
@kirrg001
Copy link
Contributor

Cool that makes sense to me 👍

@ErisDS
Copy link
Member

ErisDS commented Feb 23, 2019

To clarify a little the why - we had lots of questions about what audience should be - should it include /ghost/? What about subdirectories.. should it be the full url? If I request a token for /ghost/api/v2/admin/posts/ am I allowed to request /ghost/api/v2/admin/posts/id/ etc etc

It was p clear that the validation in place was too strict, or at least had too many unconsidered edge cases.

So, we talked about the purpose of audience, which is to narrow down what the token is for. The secret already ties a token to a specific site, so we use audience to tie a token to a specific API. This is futureproof against us having more APIs with similar auth in future.

Method and resource based restrictions can be added later, e.g. using claims.

const jwt = require('jsonwebtoken');
const JWT_OPTIONS = {
algorithm: 'HS256',
expiresIn: '5m',
audience: endpoint
audience: audience
Copy link
Contributor

Choose a reason for hiding this comment

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

@allouis FYI this is the v2 admin utility. No need to pass /admin/v2/ from tests.

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.

None yet

3 participants