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

Forbidden access #17

Closed
Alexnortung opened this issue Aug 29, 2022 · 8 comments
Closed

Forbidden access #17

Alexnortung opened this issue Aug 29, 2022 · 8 comments
Labels
bug Something isn't working

Comments

@Alexnortung
Copy link
Collaborator

Bug report

Describe the bug

After updating the plugin to version 1.0.0-alpha.5, I get an error when I try to access http://localhost:1337/api/url-alias/get?path=trust-numbers, the api returns an internal server error:

{"data":null,"error":{"status":500,"name":"InternalServerError","message":"Internal Server Error"}}

And in the development console I also get an error:

[2022-08-29 15:38:47.157] error: Forbidden access
ForbiddenError: Forbidden access
    at Object.verify (/home/alexander/source/oak-site/backend/node_modules/@strapi/plugin-users-permissions/server/strategies/users-permissions.js:94:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:31:5
    at async serve (/home/alexander/source/oak-site/backend/node_modules/koa-static/index.js:59:5)
    at async returnBodyMiddleware (/home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
    at async policiesMiddleware (/home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5)
    at async /home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/middlewares/body.js:51:9
    at async /home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/middlewares/logger.js:22:5
    at async /home/alexander/source/oak-site/backend/node_modules/@strapi/strapi/lib/middlewares/powered-by.js:16:5
    at async cors (/home/alexander/source/oak-site/backend/node_modules/@koa/cors/index.js:56:32)

Steps to reproduce the behavior

  1. Use a pre-1.0.0-alpha.5 version of this plugin (Not sure if this step is needed)
  2. Create a page content type with a title field
  3. Make a url-alias pattern on the page content type, label it slug and make the pattern /[title]
  4. Create a page and set a url with url alias
  5. Access the api /api/url-alias/get?path=[path] where path is the url you just set.
  6. See the same error.

Expected behavior

Not make an internal server error

System

  • Node.js version: v16.16.0
  • NPM version: 8.18.0
  • Strapi version:4.3.2
  • Plugin version: 1.0.0-alpha.5
  • Database: sqlite
  • Operating system: Linux - NixOS 22.05 (Quokka) x86_64
@boazpoolman
Copy link
Member

Hi @Alexnortung

Thanks for creating the new issue.
I’ll look in to it.

@boazpoolman boazpoolman added the bug Something isn't working label Aug 29, 2022
@boazpoolman
Copy link
Member

Hi @Alexnortung,

I've put up a PR to try and fix this.
I think it might be caused by the auth setting for the routes.

I've removed them completely now, can you test if that works?
That would re-open #7 though, but let's see..

yarn add strapi-community/strapi-plugin-url-alias#pull/18/head
npm install strapi-community/strapi-plugin-url-alias#pull/18/head

@Alexnortung
Copy link
Collaborator Author

Thanks @boazpoolman.

I am not experiencing the issue in the new pull request

@boazpoolman
Copy link
Member

Cool. Thanks for testing.

@sophiebl
Copy link

Hello @boazpoolman

I also get an error when I try to access: http://localhost:1337/api/url-alias/get?path=/jobs or http://localhost:1337/api/url-alias/get?path=jobs:
{"data":null,"error":{"status":403,"name":"ForbiddenError","message":"Forbidden","details":{}}}

Not sure it's a bug because I get a 403 but here is the steps to reproduce the behavior:

  1. npm install strapi-community/strapi-plugin-url-alias#pull/18/head
  2. Create the pattern:

Capture d’écran 2022-08-31 à 10 07 20

3. Create page jobs:

Capture d’écran 2022-08-31 à 10 07 42

Capture d’écran 2022-08-31 à 10 00 39

@Alexnortung
Copy link
Collaborator Author

@sophiebl have you allowed public to access the url-alias routes? under settings -> Users & Permissions plugin -> Roles -> public ?

@sophiebl
Copy link

sophiebl commented Aug 31, 2022

Thats works thanks @Alexnortung !

@boazpoolman
Copy link
Member

PR #18 was merged and released with v1.0.0-alpha.6.

If you still experience the issue beyond this version feel free to re-open the issue or create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants