funkhaus / wp-graphql-cors

Makes WP GraphQL's authetication "just work". It does this by customizing the CORS headers.
GNU General Public License v3.0
112 stars 21 forks source link

Adds replacements for wp_signon, wp_set_auth_cookie and setcookie. #20

Closed jonshipman closed 3 years ago

jonshipman commented 3 years ago

19

Adds the following functions: wpgraphql_cors_signon, wpgraphql_cors_set_auth_cookie, wpgraphql_cors_setcookie_same_site. WordPress does not have their cookies wrapped in an action so the entire functions need to be replicated. Luckily most functionality is in do_actions so most logic doesn't require duplication. The meat'n potatoes is in set-auth-cookie.php at ln65. It could probably be improved upon e.g. providing a settings bit.

Adding a filter and passing it as a last argument to wpgraphql_cors_setcookie_same_site would allow a Same Site option to be able to be passed in via configuration. However, I thought we could get this merged and then have that be a separate PR/Issue.

kidunot89 commented 3 years ago

Excellent job on this @jonshipman :+1: