Commit Graph

39638 Commits

Author SHA1 Message Date
Kevin Ansfield
a4e3ef012c Improved validation behaviour on 2fa code verification screen
closes https://linear.app/ghost/issue/ENG-1672

- removed input on-blur validation because it can be triggered when clicking reset button giving a misleading error state
- added client-side validation for 6-digit code
- added validation when submitting the form
- added error reset when typing in the code field, including removal of button failure state, so it's clearer you're in a new submit state
2024-10-21 12:32:29 +01:00
Kevin Ansfield
6c4de6a937 Updated 2fa flow copy
closes https://linear.app/tryghost/issue/ENG-1654
closes https://linear.app/tryghost/issue/ENG-1656
closes https://linear.app/tryghost/issue/ENG-1657

- updated copy
- improved error handling when verification fails
- refactored some duplication of steps in Admin authentication tests
2024-10-21 11:01:40 +01:00
Sam Lord
85d305ebf7 Added browser tests for 2fa 2024-10-21 11:01:40 +01:00
Kevin Ansfield
2bf626bf6c Added explicit 2fa required error detection
no issue

- previously we determined any 403 response was an indication that we should switch to the 2fa input screen during sign-in
- added a custom error that explicitly looks for an error with our `2FA_TOKEN_REQUIRED` code so we don't have any confusion when a non-2fa 403 is received for any reason and to have the option of moving away from the 403 if needed without breaking the client
- test to ensure our error 2fa-required error detection works correctly
- extracted duplicate steps in the authentication tests into a helper function
- fixed authentication tests so they better represent our API output of `errors` being an array
2024-10-21 11:01:40 +01:00
Kevin Ansfield
df6eb7bfda Fixed flash of button error state when redirected to 2fa screen
closes https://linear.app/tryghost/issue/ENG-1652/

- returning `undefined` from a task is equivalent to failing
- switched to returning `true` when we get the 2fa required error so the button stays in the neutral/success state
- added `SUCCESS` and `FAILURE` consts to better reflect control flow when returning from tasks and ensured we always return a value
2024-10-21 11:01:40 +01:00
Sam Lord
3ed1f6a8ca Added tests for sessions API with 2fa enabled 2024-10-21 11:01:40 +01:00
Sam Lord
eef6c64131 Added brute protection to 2FA endpoints
ref ENG-1629

Use separate protection for the 2 endpoints as one can resend an
email, and the other is used to login -- each presents its own
security challenges.
2024-10-21 11:01:40 +01:00
Michael Barrett
d90a70e43c Moved 2fa resend button inside form and added countdown 2024-10-21 11:01:40 +01:00
Sam Lord
c9c8709fd3 Added publication icon to 2fa email if available 2024-10-21 11:01:40 +01:00
Princi Vershwal
d2ca6e4a74 Added siteLogo to session service emails 2024-10-21 11:01:40 +01:00
Djordje Vlaisavljevic
548ff8d14a Updated design for 2FA verification code email
ref https://linear.app/tryghost/issue/ENG-1636/email-template-design-for-verification-code-email
2024-10-21 11:01:40 +01:00
Princi Vershwal
0c0ac6f0ab Changed subject for verification code email 2024-10-21 11:01:40 +01:00
Princi Vershwal
5ee2f91557 Added support for fetching device details when creating session 2024-10-21 11:01:40 +01:00
Michael Barrett
29d1026606 Added button to resend 2fa code
refs [ENG-1644](https://linear.app/tryghost/issue/ENG-1644/add-re-send-ui-flow)
2024-10-21 11:01:40 +01:00
Sam Lord
1f687ae466 Moved 2fa labs flag usage to avoid logging out users
After migrations run, any sessions made with the labs flag turned off
will have the verified flag set. We also need new sessions made after
that to gain the verified flag, so that they aren't logged out at the
point that the labs flag is enabled (or removed).
2024-10-21 11:01:40 +01:00
Michael Barrett
16b0ef352f Fixed 2fa code resend button reverting to retry on success
refs [ENG-1642](https://linear.app/tryghost/issue/ENG-1642/when-submitting-the-code-the-login-button-changes-to-retry-before)
2024-10-21 11:01:40 +01:00
Sam Lord
db107bd789 Fixed sendAuthCodeForUser to find user on first request
ref ENG-1641

Using `getUserFromSession` requires the cookie header to be set, but
at this point we may still be constructing the session. Instead we can
get the user id from the session itself
2024-10-21 11:01:40 +01:00
Princi Vershwal
3cffb9a132 Moved session verified check behind staff2fa flag 2024-10-21 11:01:40 +01:00
Sam Lord
cb8d18423a Fixed login / logout with 2fa code
refs ENG-1640

We had built all the right pieces, but the session endpoints weren't
verifying the service
2024-10-21 11:01:40 +01:00
Princi Vershwal
3bf0b7d8ed Added sending of 2fa code email on sign in 2024-10-21 11:01:40 +01:00
Michael Barrett
58269c879b Added migration for session verification field 2024-10-21 11:01:40 +01:00
Sam Lord
296a2be2d8 Fixed the snapshot test for the e2e suite 2024-10-21 11:01:40 +01:00
Sam Lord
f772008c69 Prevent regression / e2e tests from trying to use 2fa 2024-10-21 11:01:40 +01:00
Kevin Ansfield
1a05652b50 Added 2fa token verification error handling
closes https://linear.app/tryghost/issue/ENG-1635

# Conflicts:
#	ghost/admin/app/controllers/signin-verify.js
2024-10-21 11:01:40 +01:00
Sam Lord
5f192344f8 Switched to 1 token per minute, 10 tokens accepted
More typical in TOTP setups for each token to last 1 minute, and to
allow some older tokens.

Also moved the options setting out of the generate scope in case
verify is called first (unlikely but possible).
2024-10-21 11:01:40 +01:00
Michael Barrett
8a86db4ea5 Updated response code for re-sending verification 2024-10-21 11:01:40 +01:00
Michael Barrett
916b2aef9d Added tests for auth code middleware 2024-10-21 11:01:40 +01:00
Sam Lord
0b852bcb38 Added check for verified sessions
refs ENG-1610
2024-10-21 11:01:40 +01:00
Michael Barrett
7a18e829c5 Added endpoints for supporting 2FA
no refs

- Added `POST /session/verify` to send the user a verification code
- Added `PUT /session/verify` to verify the user's verification code
2024-10-21 11:01:40 +01:00
Princi Vershwal
51fa21324d Added logic for generating and verifying otp 2024-10-21 11:01:40 +01:00
Princi Vershwal
1106d64706 Added API for sendingAuthCode 2024-10-21 11:01:40 +01:00
Kevin Ansfield
68af12cfad Added 2fa happy path to Admin
closes https://linear.app/tryghost/issue/ENG-1617/
closes https://linear.app/tryghost/issue/ENG-1619/

- updated cookie authenticator's `authenticate` method to accept an `{identification, pasword, token}` object
  - if `token` is provided, hit our `PUT /session/verify/` endpoint passing through the token instead of hitting the `POST /session/` endpoint
- added `signin/verify` route
  - displays a 2fa code input field, including required attributes for macOS auto-fill from email/messages to work
  - uses `session.authenticate({token})` when submitted
- updated signin routine to detect token-required state
  - detects a `403` response with a `2FA_TOKEN_REQUIRED` code property when authenticating
  - if detected transitions to the `signin/verify` route
2024-10-21 11:01:40 +01:00
Paul Davis
a70e88b903 Add 2fa code email template 2024-10-21 11:01:40 +01:00
Sam Lord
8f7c81ac84 Added "verified" status to session
refs ENG-1622

Currently unused by the API, this session variable will be used to
confirm whether the user has authenticated their session with an email
OTP. The verified status is not removed on logout, so sessions are now
retained instead of being destroyed.
2024-10-21 11:01:40 +01:00
Kevin Ansfield
698e42433c Added staff2fa labs flag 2024-10-21 11:01:40 +01:00
Daniël van der Winden
db3bab4f79
Updated layout for Analytics in Settings (#21322)
fixes
https://linear.app/tryghost/issue/DES-483/improve-analytics-card-layout-in-settings

Analytics settings in admin were difficult to read, as they were all
bunched together. This change lays them out in rows, making the
Analytics settings much easier to scan.

---------

Co-authored-by: Steve Larson <9larsons@gmail.com>
Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
Co-authored-by: Cathy Sarisky <42299862+cathysarisky@users.noreply.github.com>
Co-authored-by: Ghost CI <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: jubi-git <117194340+jubi-git@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-21 09:44:48 +00:00
renovate[bot]
17892c6a99 Update dependency i18next to v23.16.2 2024-10-21 00:58:33 +00:00
Steve Larson
d1db417495
Reduced apps package size (#21349)
ref 324211f
- this includes changes to improve package size

Package size was found to be bloated due to expanding i18n strings. We
were packing all i18n strings instead of just the ones relevant to the
package. Thanks to @cathysarisky for identifying this!
2024-10-20 13:47:15 +00:00
jubi-git
d122d9b2fa
🌐 Added Dutch (nl) locale for search.json (#21339)
no ref
2024-10-20 13:31:49 +00:00
Steve Larson
1a37e77f6a
Bumped signup-form (#21348)
no ref
2024-10-20 13:30:31 +00:00
Steve Larson
f759f1e042
Bumped comments-ui (#21347)
no ref
2024-10-20 08:28:32 -05:00
Steve Larson
4f28e7ea43
Bumped sodo-search (#21346)
no ref
2024-10-20 13:24:21 +00:00
Steve Larson
a01b361e45
Bumped portal (#21345)
no ref
2024-10-20 13:22:46 +00:00
Ghost CI
e42ed553dc v5.97.0 2024-10-18 15:05:19 +00:00
Cathy Sarisky
324211f64d
fix build for search, signup, comments = 80-90% reduction in size! (#21342)
no ref

This change to vite.config.js fixes errors in the sodo-search,
signup-form, and comments packages, preventing inclusion of all of
i18n/locales. As the number of translated strings has gotten larger,
these builds have increased significantly in size, bloated with strings
that aren't actually present in them (in 58 different languages!)

No obvious build errors are present with these changes, but an extra
eyes would be appreciated. Vite isn't my forte.

---------

Co-authored-by: Steve Larson <9larsons@gmail.com>
2024-10-17 12:35:56 -05:00
Kevin Ansfield
2fb88e65ca Fixed signin and signup button failure state hover colors
ref https://linear.app/tryghost/issue/ENG-1653

- we were always setting a `style="background-color: #123456"` attribute on the buttons but that didn't allow for different button states such as the red failure state to correctly override meaning there was some odd behaviour when hovering
- removed the fixed `style` attribute and adjusted `<GhTaskButton>`
  - added `@useAccentColor` prop
  - when `@useAccentColor` is true, add the necessary `style` attribute except when showing the failure state
2024-10-17 16:54:23 +01:00
Steve Larson
2e0293c99f
🐛 Fixed NQL filters for single letter slugs (#21340)
fixes https://github.com/TryGhost/Ghost/issues/20133
- includes fix to support single letter slugs
2024-10-17 15:35:26 +00:00
Daniël van der Winden
eaed33972f
Admin navigation settings fix (#21323)
fixes
https://linear.app/tryghost/issue/DES-73/enter-should-create-new-navigation-itemmove-to-next-field

Solves a regression where, when adding navigation items, pressing ENTER
(when on the last item in the list) no longer created a new row.

Also solves an issue where the `+` button next to the row of input
fields wasn't positioned correctly when a form error was showing (it
jumped down along with the error).
2024-10-17 13:10:21 +00:00
Aileen Booker
3eb6503849 Added migration for new settings keys 2024-10-17 05:51:38 -04:00
Chris Raible
0e10f500aa
Added target dependencies to test scripts in ghost/core (#21332)
no issue

- The `test:*` commands in `ghost/core` are all implicitly dependent on
the TS packages in the whole monorepo being built, but we hadn't
explicitly declared this dependency to NX.
- Now if you run `yarn nx run ghost:test:e2e` (or any other `test:*`
commands in ghost), NX will know that it needs to rebuild the TS
packages, unless they are cached and haven't changed.
- With this, you should be able to directly clone the repo and run `yarn
nx run ghost:test:e2e` to run e2e tests, without running `yarn dev` or
`yarn nx run-many -t build:ts` first.
- This is especially useful for getting tests to run properly in docker
2024-10-16 14:12:20 -07:00