Skip to content

fix(gatsby-source-wordpress): allow using engines when using wordpress auth#38103

Merged
pieh merged 1 commit intomasterfrom
fix/wordpress-auth-engines
May 25, 2023
Merged

fix(gatsby-source-wordpress): allow using engines when using wordpress auth#38103
pieh merged 1 commit intomasterfrom
fix/wordpress-auth-engines

Conversation

@pieh
Copy link
Copy Markdown
Contributor

@pieh pieh commented May 22, 2023

Description

#32303 removes options.auth from plugin options to prevent leaking them to browser. However this later causes problems for engines as they are missing auth information.

This PR keeps removal of auth, but it restores it later after browser plugin options is written out. Above PR added tests to ensure secrets are not leaked, so we should be still guarded against that

Documentation

Tests

Related Issues

…s auth

Co-authored-by: Lennart <lekoarts@gmail.com>
@gatsbot gatsbot Bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 22, 2023
@pieh pieh added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 22, 2023
@pieh pieh marked this pull request as ready for review May 22, 2023 10:51
import type { Step } from "./../utils/run-steps"
import type { IPluginOptions } from "~/models/gatsby-api"

let storedAuthSettings: IPluginOptions["auth"] | undefined
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not greatest to store as module variable, but I lack context on this plugin internals, so if there is a better way - happy to adjust

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is ok. The plugins internals aren't great 😜 wish I could undo the way it manages state so this is preferrable imo.

Comment on lines +17 to +21
exports.onPreBootstrap = runApiSteps(
[steps.restoreAuthPluginOptions],
`onPreBootstrap`
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this runs after we write out browser plugin options and before bundling engines, so good spot to do restoration

@pieh pieh merged commit 7adb331 into master May 25, 2023
@pieh pieh deleted the fix/wordpress-auth-engines branch May 25, 2023 10:27
pieh added a commit that referenced this pull request May 25, 2023
…s auth (#38103)

Co-authored-by: Lennart <lekoarts@gmail.com>
(cherry picked from commit 7adb331)
pieh added a commit that referenced this pull request May 25, 2023
…s auth (#38103)

Co-authored-by: Lennart <lekoarts@gmail.com>
(cherry picked from commit 7adb331)
pieh added a commit that referenced this pull request May 25, 2023
…s auth (#38103)

Co-authored-by: Lennart <lekoarts@gmail.com>
(cherry picked from commit 7adb331)
pieh added a commit that referenced this pull request May 25, 2023
…s auth (#38103) (#38109)

Co-authored-by: Lennart <lekoarts@gmail.com>
(cherry picked from commit 7adb331)

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
pieh added a commit that referenced this pull request May 25, 2023
…s auth (#38103) (#38112)

Co-authored-by: Lennart <lekoarts@gmail.com>
(cherry picked from commit 7adb331)

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
@pieh
Copy link
Copy Markdown
Contributor Author

pieh commented May 25, 2023

Published in

  • gatsby-source-wordpress@6.25.5 (Gatsby v4 release line)
  • gatsby-source-wordpress@7.10.1 (Gatsby v5 release line)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: source-wordpress Related to Gatsby's integration with WordPress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants