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

Internal Proxy Cookies & docker-latest #80

Open
tamaskan opened this issue Apr 1, 2024 · 15 comments · May be fixed by #87
Open

Internal Proxy Cookies & docker-latest #80

tamaskan opened this issue Apr 1, 2024 · 15 comments · May be fixed by #87
Assignees
Labels
enhancement New feature or request

Comments

@tamaskan
Copy link

tamaskan commented Apr 1, 2024

According to https://stackoverflow.com/questions/47870786/express-proxy-api-calls-with-cookie it seems possible to add the cookies from the initial request to the proxy request, therefore enabling cookie-based sso

The :latest seems to point to version 0.26 (probably because of the breaking changes). That should be mentioned

@goniszewski
Copy link
Owner

Hi @tamaskan! Let me look into it shortly. Thank you for spotting this possible improvement.

As for the Docker tags, 0.3.0, 0.3, latest, and main are pointing to the same image at the moment.

@tamaskan
Copy link
Author

tamaskan commented Apr 1, 2024

Shouldn't they have the same digest then ? https://hub.docker.com/r/goniszewski/grimoire/tags

@goniszewski
Copy link
Owner

As I can see in the CI log on GitHub, the push to the main branch and an actual release fired the workflow separately. Because of the different SHA of those commits, the digest value also differs.:

@goniszewski goniszewski self-assigned this Apr 2, 2024
@goniszewski goniszewski added the enhancement New feature or request label Apr 2, 2024
@tamaskan
Copy link
Author

tamaskan commented Apr 2, 2024

Thanks for clarifying. I was wondering why the package.json on main is still on 0.2.6 ( https://github.com/goniszewski/grimoire/blob/main/package.json )

@goniszewski
Copy link
Owner

@tamaskan it should be updated automatically, but for some reason wasn't.

I looked into the documentation, and it looks like cookies are always passed to the proxy request. We don't need to overwrite them. Or maybe do you have something different in mind?

@tamaskan
Copy link
Author

tamaskan commented Apr 4, 2024

I think i found my issue. In pb.ts it seems that only an internal pocketbase-installation can be used when is_dev is true

@goniszewski
Copy link
Owner

I see there's a wrong port being specified for the default on DEV: should be http://localhost:8090 instead of `http://localhost:5173".

It's now fixed on latest and main. Sorry for that!

As for the logic behind PB URLs for specified environments:

  • production: defaults to proxy (<PUBLIC_ORIGIN>/internal/pb) which then uses PUBLIC_POCKETBASE_URL if set or defaults to http://pocketbase (default PB container host using internal Docker network)
  • development: doesn't use proxy, but directly connects to PUBLIC_POCKETBASE_URL if set or defaults to http://localhost:8090

@tamaskan
Copy link
Author

tamaskan commented Apr 4, 2024

I see. My problem is that executing an internal call to <PUBLIC_ORIGIN>/internal/pb is missing the cookies to bypass the sso on this url

@goniszewski
Copy link
Owner

Ok, I thought it was a problem with the auth cookie for PocketBase auth.

We can add some way to inject additional headers. The simplest solution would be to store stringified representation of additional headers in .env file, and then just parse and inject it. But maybe there's a more elegant way to do it :)

@tamaskan
Copy link
Author

tamaskan commented Apr 4, 2024

that would be a beautiful solution :-)

@goniszewski
Copy link
Owner

@tamaskan could you review the changes from the linked PR? If yes, it would be great to have your opinion on this implementation!

@tamaskan
Copy link
Author

tamaskan commented Apr 8, 2024

isn't it missing the variable-assignment in dockerfile ?

@goniszewski
Copy link
Owner

Yes, indeed 😄 Fixed!

@tamaskan
Copy link
Author

I was able to build the branch with "--no-cache" in Dockerfile (segfaulting without).
It wasn't working until i added the headers to the initial pocketbase-connection like this pocketbase/pocketbase#2618 in src/lib/pb.ts . I am currently not able to test it further (heritage yee is not an object or null-error)

@goniszewski
Copy link
Owner

@tamaskan the error you're referring to, heritage yee, should be now resolved in https://github.com/goniszewski/grimoire/releases/tag/v0.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants