Base solution for your next web application

Activities of "exaas"

  • What is your product version? 11.1.0
  • What is your product type (Angular or MVC)? ASP.NET Core MVC
  • What is product framework type (.net framework or .net core)? .NET Core

Not sure if this is documented anywhere so I did my best to get this working, however I am not sure it is a valid method or if it will break during upgrades in the future. There appears to be some missing information around authenticating/registering new users with OpenID and Azure AD.

Here are my steps I created in our Wiki, let me know if I need to consider modifications that may be best suited for the future of this framework (I have not tested in our test environment yet):


To utilize Azure AD authentication and user registration with OpenID connect, we had to enable social logins in our ANZ app, register a new application Azure AD, enable OpenID in ANZ app and fill in custom details for OpenID, provide the Azure AD application with custom claims, and modify DefaultExternalLoginInfoManager class to support the correct username.

In your ASPNETZERO project, open appsettings.json and enable social logins:

In Azure AD, navigate to "App registrations":

Select "New registration":

Give your application a name (this can be anything you want):

Select your Supported account types (in our case we want all options):

Set your Redirect URI:

Click Register to complete setup of your application.

Open your newly registered Azure AD app and select Authentication:

Add additional Redirect URIs:

Add a Front-channel logout URL:

Select "ID tokens" for your Implicit grant and hybrid flows:

Save your changes.

Navigate to Certificates & Secrets:

Create New client secret:

Provide a description and expiration time and click Add:

You will see your new client secret; document the "Value", you will only see it this one time:

Find your Client ID on the Overview tab :

You configure your appsettings.json OpenID settings as follows:

Provide custom claims within your Azure AD app buy selecting "Token configuration"

Select "Add optional claim":

Select ID as the Token type and then "email" from the Claim list:

Click Add, you will get a prompt, select the check box and click Add:

Now you need to modify your DefaultExternalLoginInfoManager.cs file to get the correct username:

*Without making this change, you user will register with a MD5 value.

Run your application and test on the Default tenant to register a user

Screenshots from the login process:

@ismcagdas

You are right, it appears my screenshots only showed up for me using WYSIWYG editor. Let me clean them up with actual images and test in another browser.

As for the blog post, absolutly I would like that, if it will help someone else. Let me get the format cleaned up with the images.

Thanks.

  • VS2022 64bit Enterprise
  • AspNetZero Version 11.3 - ASP.NET Core & jQuery
  • Windows 10 Pro

Started with new installation of ANZ following getting started guide. Branch from Dev to new branch. Ran and tested before using Power Tools...all was good,

Simple Contacts entity, all strings, very simple, git an error at the end:

Build solution resulted in some errors:

Navigation placed in wrong location: * manually fixed.

Is this normal behavior is using the root option in Power Tools? Is the error message something I can fix with config changes in Power Tools?

The build worked after my manual fixes, but not sure if there will be adverse effects.

On version 12.0.0, Asp.Net Core MVC/jQuery.

The latest release has a bug with the login page. When clicking on "Change" to switch tenant, nothing happens. The URL simply appends a "#".

Example: https://localhost:44302/Account/Login#

Tested on version 11.3.0 and the function worked correctly.

Any thoughts?

Looks like it was fixed in 12.0.1. I migrated to update version and it is working. Thanks.

Version: ASP.NET Core MVC & jQuery version 12.0.1

Looks like there are some changes required for Stripe integration to work. Stripe updated their API so line_items no longer work: https://stripe.com/docs/upgrades#2022-08-01

StripePaymentAppService.cs lines 188-192

                        Amount = (long) _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                        Name = StripeGatewayManager.ProductName,
                        Currency = myProjectConsts.Currency,
                        Description = payment.Description,
                        Quantity = 1

I changed them to this:

                        //Price = _stripeGatewayManager.ConvertToStripePrice(payment.Amount).ToString(),
                        PriceData  = new SessionLineItemPriceDataOptions()
                        {
                            UnitAmount = _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                            Currency = myProjectConsts.Currency,                 
                            ProductData = new SessionLineItemPriceDataProductDataOptions()
                            {
                                Name= StripeGatewayManager.ProductName,
                                Description = payment.Description
                            },
                        },
                        //Amount = (long) _stripeGatewayManager.ConvertToStripePrice(payment.Amount),
                        //Name = StripeGatewayManager.ProductName,
                        //Currency = myProjectConsts.Currency,
                        //Description = payment.Description,
                        Quantity = 1,

Also on line 161 I added Mode:

            {
                Mode = "payment",
                PaymentMethodTypes = paymentTypes,
                SuccessUrl = input.SuccessUrl + (input.SuccessUrl.Contains("?") ? "&" : "?") +
                             "sessionId={CHECKOUT_SESSION_ID}",
                CancelUrl = input.CancelUrl
            };

Those changes seemed to allow me to use Stripe, but during testing I was provided a new error message.

In the US, we do not use Tax/VATNo for most transactions, and never for personal transactions. In this case, someone simply signing up for service as a user, not a business.

What can be done here to avoid this error? I am thinking just modify the existing code for InvoiceAppService to exclude Tax info and passing the users name and address from Stripe, but I wasn't sure if I was missing something that may make this a bit easier...like a const setting perhaps?

Thoughts?

Found the Stripe fix on the github: https://github.com/aspnetzero/aspnet-zero-core/pull/4753/files/5e80799f97a0b3854f417f32a092559cc1a13c8a

That helps.

I implemented the changes per github, but during testing with Stripe, it gets to the receiving payment result and never completes. I stripe I continues to create a new user each time it checks payment status:

I am going to try this live to see if i get a different result.

Found the issue, I was confused about the minimum payment amount and how it worked.

Default is set to what looks like $1million (1M): https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Features-Mvc-Core-Subscription

I changed this to "50", which is Stripe's minimum accepted payment amount (for testing), and the transaction completed and activated the account.

I am still confused about how to handle the Tax/VATNo for the US users that are not businesses, but I will ask this in a new/different thread.

Thanks.

I am working on an app that will allow both individuals and businesses, however, there is no requirement in the US to have people, even businesses enter their Tax ID's such as Social Security Numbers or Employer Identification Number. This is how I interpret the requirement to view and Invoice is to enter either SSN or EIN, which many will not due simply because of PII and Health data being saved.

Is there an alternative or what options can be used, specifically to automate this? Perhaps there is some logic that can be applied for US users since may will not know what a Tax ID or VAT number is.

Thoughts? I was hoping not to have to modify the source code for Invoices as to avoid too many conflicts with future released.

Perhaps this is more similar to "Sales Tax"? Each state within the US will have it's own tax amount for sales of goods, and then each county and city will sometimes have additional sales tax amounts for purchases. So perhaps that is the meaning of this field...to use perhaps a Zip Code for the US to identify tax nexus?

Some direction would be helpful here, or ideas.

Thanks.

Showing 1 to 10 of 11 entries