ShopifexWeb.Routes (Shopifex v3.0.0)

Copy Markdown View Source

Provides macros for easily responding to Shopify requests within your Shopifex router.

pipelines

Call the pipelines macro in your router to inject some standard router pipelines into your router module. These pipelines can be used for responding to webhooks, admin links, proxy requests, and requests to load your app within the Shopify admin.

auth routes

Call the auth_routes macro in your router to inject the standard Shopify app routes which your app will need. This includes routes for loading the app in Shopfiy the admin, app installation and app updates.

payment routes

Call the payment_routes macro in your router to inject the routes required by the Shopifex PaymentGuard system.

Summary

Functions

Injects the following Shopify router pipelines into your Shopifex application's router.

Generate a live session with the current_shop and session token assigned. All other options are passed through to live_session.

Functions

auth_routes(controller \\ ShopifexWeb.AuthController)

(macro)

payment_routes(controller \\ ShopifexWeb.PaymentController, opts \\ [])

(macro)

pipelines()

(macro)

Injects the following Shopify router pipelines into your Shopifex application's router.

  • :shopifex_browser: Same as your normal :browser pipeline, except it calls Shopifex.Plug.LoadInIframe, which removes the x-frame-options header and the frame-ancestors 'self' CSP directive that put_secure_browser_headers sets.
  • :managed_install: Runs Shopifex.Plug.ManagedInstall — verifies Shopify's id_token, exchanges it for an expiring offline access token, and builds the session. Included in auth_routes/1 before :shopify_session.
  • :shopify_session: Verifies the App Bridge session token (id_token), or the legacy install HMAC, and makes session information available via Shopifex.Plug API. No-ops when an earlier :managed_install already loaded the shop. Also removes iFrame blocking headers so app can render in Shopify admin.
  • :validate_install_hmac: Runs Shopifex.Plug.ValidateHmac only. Used by the legacy OAuth /auth/install and /auth/update routes, which verify the query HMAC without loading a shop into the session.
  • :shopify_webhook: Validates Shopify webhook requests HMAC and makes session information available via Shopifex.Plug API.
  • :shopify_proxy: Validates Shopify App proxy requests (signed with signature, not hmac, and require_timestamp: true) via Shopifex.Plug.ValidateHmac, then resolves the shop with Shopifex.Plug.LoadProxyShop.
  • :shopify_admin_link: Validates Shopify admin link & bulk action link requests and makes session information available via Shopifex.Plug API. Also removes iFrame blocking headers so app can render in Shopify admin.
  • :shopify_api: Ensures that a valid Shopify App Bridge session token (id_token) is present in the Authorization header. Useful for async requests between your SPA front end and Shopifex backend.
  • :shopifex_api: Alias of :shopify_api (same Shopifex.Plug.ShopifyApiAuth behind CORS + JSON), under the shopifex_-prefixed name.
  • :shopify_embedded: Sets Content-Security-Policy headers to restrict app loading to within the Shopify admin. Read more: https://shopify.dev/apps/store/security/iframe-protection#embedded-apps

shopifex_live_session(session_name, opts \\ [], list)

(macro)

Generate a live session with the current_shop and session token assigned. All other options are passed through to live_session.