Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #493 from Shopify/auth-case-insensitive
Browse files Browse the repository at this point in the history
koa-shopify-auth: Accept mixed-case shop parameters
  • Loading branch information
tylerball authored Feb 6, 2019
2 parents c687183 + c2e41ba commit 6e94d3a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/koa-shopify-auth/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

---

## 3.1.12 - 2019-02-05

### Fixed

- OAuth route no longer rejects uppercase shop domains [#493](https://github.com/Shopify/quilt/pull/493)

## 3.1.11 - 2019-01-10

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/koa-shopify-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shopify/koa-shopify-auth",
"version": "3.1.13",
"version": "3.1.12",
"license": "MIT",
"description": "",
"main": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/koa-shopify-auth/src/auth/create-oauth-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function createOAuthStart(

const shopRegex = new RegExp(
`^[a-z0-9][a-z0-9\\-]*[a-z0-9]\\.${myShopifyDomain}$`,
'i',
);

if (shop == null || !shopRegex.test(shop)) {
Expand Down
16 changes: 16 additions & 0 deletions packages/koa-shopify-auth/src/auth/test/oauth-start.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const baseUrl = 'myapp.com/auth';
const callbackPath = '/callback';
const shop = 'sho-p1.myshopify.io';
const badShop = 'shop1myshopify.io';
const uppercaseShop = 'SHO-P1.myshopify.io';
const redirectionURL = `/admin/oauth/authorize`;

const baseConfig: OAuthStartOptions = {
Expand Down Expand Up @@ -80,4 +81,19 @@ describe('OAuthStart', () => {
`https://${shop}${redirectionURL}?abc=123`,
);
});

it('accepts mixed-case shop parameters', () => {
const oAuthStart = createOAuthStart(baseConfig, callbackPath);
const ctx = createMockContext({
url: `https://${baseUrl}?${query({shop: uppercaseShop})}`,
});

(oAuthQueryString as any).mockReturnValueOnce('');

oAuthStart(ctx);

expect(ctx.redirect).toBeCalledWith(
`https://${uppercaseShop}${redirectionURL}?`,
);
});
});

0 comments on commit 6e94d3a

Please sign in to comment.