Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shopify provider #207

Closed
wants to merge 5 commits into from
Closed

Conversation

ChrisInSeattle
Copy link

I wrote a Shopify provider. My first try at this, sooo.. that's my excuse if there's anything wacky here.

Unfortunately, I had to pollute AuthenticationController.cs in the MVC sample to demo this. Shopify is wonky in that you need the shop host name before you can construct the authorization uri.

Thanks,
Chris

// Shopify OAuth differs from most (all?) others in that you need to know the host name of the
// shop in order to construct the authorization endpoint. This can be aquired either from the
// user directly, or provided by the shopify app store during app install/activation.
var authProps = new ShopifyAuthenticationProperties("ctest-205") // Put your shop name here.
Copy link
Member

Choose a reason for hiding this comment

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

Could you put all the Shopify-specific code into its own method and do if Shopify (do other thing)? Otherwise the code reads as it's mainly for Shopify, rather than the other way around.

Copy link
Author

Choose a reason for hiding this comment

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

Hey Martin, sorry to have let this sit so long. I was diagnosed with leukemia about 3 days after I submitted the PR. I'm still only working half time and have about a year's worth of backlogged tasks. I really appreciate all your comments! I'll try to find some time for this asap.

Copy link
Member

Choose a reason for hiding this comment

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

No problem, Chris - I've only recently become a maintainer myself, and I went through all the PRs and issues to either push them forwards or close them off.

A future update to re-implement this would be great if you manage find the time 😃

Copy link
Member

Choose a reason for hiding this comment

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

I was diagnosed with leukemia about 3 days after I submitted the PR.

@ChrisInSeattle I'm really sorry to hear that. I wish you a speedy recovery. Take care of you! 🤞


.AddShopify(options =>
{
options.ApiKey = "9489b7555256142d9d723711c4614df7";
Copy link
Member

Choose a reason for hiding this comment

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

Would you be OK with your keys living in the sample and being used by potentially anyone?

<FileVersion>2.0.0.0</FileVersion>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<Version>1.0.1</Version>
Copy link
Member

Choose a reason for hiding this comment

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

A lot of these properties are redundant as they defined centrally in the source code.

<Version>1.0.1</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Copy link
Member

Choose a reason for hiding this comment

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

Delete this PropertyGroup.

</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
Copy link
Member

Choose a reason for hiding this comment

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

Versions are defined centrally in MSBuild properties.

/// <summary>
/// Claim valueType used for boolean claims.
/// </summary>
public const string XmlSchemaBoolean = "http://www.w3.org/2001/XMLSchema#boolean";
Copy link
Member

Choose a reason for hiding this comment

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

/// <summary>
/// Claim valueType used for dateTime claims (iso format)
/// </summary>
public const string XmlSchemaDateTime = "http://www.w3.org/2001/XMLSchema#dateTime";
Copy link
Member

Choose a reason for hiding this comment

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

/// <summary>
/// An alias for <see cref="OAuthOptions.ClientId"/>
/// </summary>
public string ApiKey
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need these aliases?


private void SetProperty(string propName, string value)
{
if (Items.ContainsKey(propName))
Copy link
Member

Choose a reason for hiding this comment

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

Use TryGetValue().

/// to authorize. This must either be gotten from the user or sent from Shopify during App store
/// installation.
/// </param>
public ShopifyAuthenticationProperties(string shopName)
Copy link
Member

Choose a reason for hiding this comment

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

Constructor before properties for code consistency please.

@martincostello
Copy link
Member

Thanks for the PR @ChrisInSeattle - as part of the preparation for ASP.NET Core 3.0 support, tests are being added to help make things easier to maintain and validate going forwards (see #292).

Once tests are merged into the dev branch, could you copy the approach to add tests for the new provider into this PR please? It looks like it also needs re-basing with the dev branch.

@martincostello
Copy link
Member

#280 has been merged to dev now. If you rebase and update any tests as appropriate, thanks.

@martincostello martincostello removed this from the 2.1.0 milestone May 24, 2019
@martincostello
Copy link
Member

Closing due to inactivity and merge conflicts - please re-open and rebase if you would like to pursue adding a provider for Shopify in a future release.

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

Successfully merging this pull request may close these issues.

3 participants