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

Make this site private - not working in Chrome and Opera #17514

Open
1 task done
joe-blocher opened this issue Jul 27, 2023 · 18 comments · Fixed by #17938
Open
1 task done

Make this site private - not working in Chrome and Opera #17514

joe-blocher opened this issue Jul 27, 2023 · 18 comments · Fixed by #17938
Labels
bug [triage] something behaving unexpectedly

Comments

@joe-blocher
Copy link
Contributor

joe-blocher commented Jul 27, 2023

Issue Summary

Change or delete the row 58:
versions/5.54.4/core/frontend/apps/private-blogging/lib/middleware.js

return session({
           name: 'ghost-private',
           maxAge: constants.ONE_MONTH_MS,
           signed: false,
           sameSite: 'lax'     <----- row 58: instead of 'none' or delete row
       })(req, res, next);

Or you can delete the row 58 because sameSite: 'Lax' is the default value.
You can't code 'secure' within an object - secure: true will not work.

Works now in Chrome and Opera.
See https://web.dev/i18n/en/samesite-cookies-explained
x (1) Mark cross-site cookies as Secure to allow setting them in cross-site contexts

Steps to Reproduce

See https://forum.ghost.org/t/make-this-site-private-not-working/39938/1

Ghost Version

5.54.4

Node.js Version

v18.15.0

How did you install Ghost?

local, macos

Database type

SQLite3

Browser & OS version

No response

Relevant log / error output

No response

Code of Conduct

  • I agree to be friendly and polite to people in this repository
@github-actions github-actions bot added the needs:triage [triage] this needs to be triaged by the Ghost team label Jul 27, 2023
@joe-blocher
Copy link
Contributor Author

joe-blocher commented Jul 27, 2023

Maybe you can implement, like the 'ghost-admin-api-session':
versions/5.54.4/core/server/services/auth/session/express-session.js

function getExpressSessionMiddleware() {
            ...
           name: 'ghost-admin-api-session',
            cookie: {
                maxAge: constants.SIX_MONTH_MS,
                httpOnly: true,
                path: urlUtils.getSubdir() + '/ghost',
                sameSite: urlUtils.isSSL(config.get('url')) ? 'none' : 'lax',
                secure: urlUtils.isSSL(config.get('url'))
            }
        });
    }
    return unoExpressSessionMiddleware;
}

@github-actions
Copy link
Contributor

This issue is currently awaiting triage from @daniellockyer. We're having a busy time right now, but we'll update this issue ASAP. If you have any more information to help us triage faster please leave us some comments. Thank you for understanding 🙂

@joe-blocher
Copy link
Contributor Author

In core/frontend/apps/private-blogging/lib/middleware.js:

´´´
const privateBlogging = {

    …
    return session({
        name: 'ghost-private',
        maxAge: constants.ONE_MONTH_MS,
        signed: false,
  //      sameSite: 'none'    <——— replace this with 2 lines below 
          sameSite: urlUtils.isSSL(config.get('url')) ? 'none' : 'lax',
          secure: urlUtils.isSSL(config.get('url'))
    })(req, res, next);
},

´´´

and all is fine!
Implement in the same way as you did in
core/server/services/auth/session/express-session.js

@github-actions
Copy link
Contributor

This issue is currently awaiting triage from @daniellockyer. We're having a busy time right now, but we'll update this issue ASAP. If you have any more information to help us triage faster please leave us some comments. Thank you for understanding 🙂

@daniellockyer daniellockyer added the bug [triage] something behaving unexpectedly label Sep 1, 2023
@github-actions github-actions bot removed the needs:triage [triage] this needs to be triaged by the Ghost team label Sep 1, 2023
@daniellockyer
Copy link
Member

Hey there, thank you so much for the detailed bug report.

That does look like something that shouldn't happen! A PR to fix this issue would be very welcome 🙂

joe-blocher added a commit to joe-blocher/Ghost that referenced this issue Sep 2, 2023
"Make this site private" - not working in Chrome and Opera
Closes TryGhost#17514
@joe-blocher
Copy link
Contributor Author

I have made the PR

@hussainb
Copy link

Hi, I am facing the same issue in the latest version of Ghost, unable to login to the private site using Chrome based browsers.

@joe-blocher
Copy link
Contributor Author

It's nearly three month later ... an nothing happened. But for me it closed, because I'm working locally :-)
https://forum.ghost.org/t/make-this-site-private-not-working/39938

@hussainb
Copy link

It's nearly three month later ... an nothing happened. But for me it closed, because I'm working locally :-) https://forum.ghost.org/t/make-this-site-private-not-working/39938

yeah, they didn't care to merge it. but I appreciate you for your troubleshooting and the fix.

I think just a rerun would be required to pass the build, otherwise the PR is already approved:

https://github.com/TryGhost/Ghost/actions/runs/6057836235/job/16821076886?pr=17938
image

@joe-blocher
Copy link
Contributor Author

joe-blocher commented Oct 16, 2023 via email

@hussainb
Copy link

Maybe @daniellockyer can help

daniellockyer pushed a commit that referenced this issue Oct 16, 2023
fixes #17514

- good explanation in #17938 (comment)
- fixes setting the private mode cookie in stricter browsers for local development
@joe-blocher joe-blocher reopened this Apr 18, 2024
@joe-blocher
Copy link
Contributor Author

You did't fix the error: Make this site private - not working not working in Chrome and Opera

Bildschirmfoto 2024-04-18 um 10 34 22
Bildschirmfoto 2024-04-18 um 10 35 30

SOLUTION - it told you in August 2023 and I have made the PR!

versions/5.82.2/core/frontend/apps/private-blogging/lib/middleware.js

`const privateBlogging = {
....

    return session({
        name: 'ghost-private',
        maxAge: constants.ONE_MONTH_MS,
        signed: false,

        sameSite:   urlUtils.isSSL(config.get('url')) ? 'none' : 'lax',  <------------ insert this
        secure: urlUtils.isSSL(config.get('url'))  <------------------------------ insert this
        //sameSite: 'none' <------------------------------------------  row 58: remove
    })(req, res, next);
},`

@joe-blocher
Copy link
Contributor Author

joe-blocher commented Apr 20, 2024

The pull request still not merged in version 5.82.2:
Fixed private mode cookie for local development #17938

Why not?

@vikaspotluri123
Copy link
Member

What makes you say the PR wasn't merged? The commit shows that it's been in releases starting from 5.70.0.

@joe-blocher
Copy link
Contributor Author

joe-blocher commented Apr 20, 2024

I've downloaded the code:
versions/5.82.2/core/frontend/apps/private-blogging/lib/middleware.js
But the code is still the same:
return session({ name: 'ghost-private', maxAge: constants.ONE_MONTH_MS, signed: false, sameSite: 'none' <------------------------------------------ why this? })(req, res, next); },

@vikaspotluri123
Copy link
Member

The code being the same does not mean your PR was not merged. In this case it looks like this change ended up possibly breaking something else so it was reverted:

#19298

@davedub
Copy link

davedub commented May 3, 2024

The code being the same does not mean your PR was not merged. In this case it looks like this change ended up possibly breaking something else so it was reverted:

#19298

OK so that means it is still a problem. I am running 5.79.6 (released Feb 26) and cannot make the site private because of this bug. What's the ETA on solving this?

@joe-blocher
Copy link
Contributor Author

The code being the same does not mean your PR was not merged. In this case it looks like this change ended up possibly breaking something else so it was reverted:
#19298

OK so that means it is still a problem. I am running 5.79.6 (released Feb 26) and cannot make the site private because of this bug. What's the ETA on solving this?

My solution:
I change always the code by myself, when I install an update. You have to change only 2 lines.
The first time I reported the solution in August 2023.
Maybe they will fix the bug sometimes ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [triage] something behaving unexpectedly
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants