Showing posts with label SPA. Show all posts
Showing posts with label SPA. Show all posts

Thursday, March 19, 2020

Implementing Azure Ad B2C with MSAL.js in SPA with aspnetcore api

In the previous article Implicit Flow in SPA with Azure Ad I tried to learn how to use the Azure Ad Implicit flow to login to Single Page Application.

Azure AD B2C documentation on Microsoft is very elaborate and will take you through the steps from Creating a tenant in Azure to running an application.

Currently, you cannot create an Azure B2C tenant in Australia

If you have gone through the previous article, I had use MSAL.js in the client app to implement the login flow.

If you want to follow the steps you can refer the code hosted on Github AzureAd Samples under the SPA_B2C folder.

I have tried to implement only signup and sign-in flow.

If you follow the steps in the documentation you will have an Azure Ad B2c tenant and user flow to sign in and sign up a user.

you would need to create a .env.developement file next to the .env file in the root folder and update the following variables

REACT_APP_CLIENT_ID=
 REACT_APP_TENANT_ID= 
REACT_APP_TENANT_NAME= 
REACT_APP_SUSI_FLOW_ID= 

If you do not know about React environment variables have a read at Adding custom environment variables


Also, I am loading the SPA from the aspnet core web app. So in my case, the redirect URL in the app registration is https://localhost:44321, which can be found in the launchSettings.json

If you run the aspnet core web app and navigate to https://localhost:44321 on your favorite browser. you will see an empty page with a Sign-in button.


There are 2 flows that can be used


- Popup flow where a separate popup window will open to login
- Redirect flow

If you just check out the repo you will see the redirect flow and if you wanna see the popup action you need to be on the corresponding commit

There are some known issues with IE.

If everything is configured properly you should see your custom ui page after clicking the login button

You can hit sign up to register a new user.

Note: The order of the fields on the signup page will be what is set in the Page layouts in the Azure Ad B2C. If, you want to chage the order you can do in Azure



Also, you can set which fields are optional or not.

You will need a real email for verification. This is the first step in the registration process.

After you get the email with verification code you can finish the registration process.

If the user is created successfully and logged in you will see the next page in the app.


logout button does not work at the time when I am writing this article but it may be in when you are reading :)

Next article I will be doing how to access the API and get the weather summaries.

Cheers

Happy coding.







Wednesday, August 12, 2015

Hybrid App Development Part 1

So, in the previous blog Introduction to hybrid app development we learn about what is hybrid app. Today, we will learn more about hybrid app.
  1. Hybrid App Architecture : Hybrid App Development Part 1
  2. Development tools           : Hybrid App Development Part 2
  3. Debugging techniques      : Hybrid App Development Part 3
  4. Building Hybrid App        : Hybrid App Development Part 4
    1. UI Development     : Part 4.1
    2. Fetching Data and Angular Caching : Part 4.2
  5. Testing the App                : Hybrid App Development Part 5
  6. Deployment of App          : Hybrid App Development Part 6
We will talk about Architecture of Hybrid Mobile Application. We will discuss each of the component in detail. 

So first question that came to my mind when I think of Hybrid App Development is that what is it that enables this?


Answer to this Question is