Sign in users using AspNetCore.Identity
(.NET 8 RC2
) in a Blazor Server app using cookie authentication and call a protected API using API Key authentication.
Run both of the projects, login using Username: ashish@example.com
and Password: Password123!
.
Navigate to Weather page and you can see the weather data being fetched from a secured API:
![image](https://private-user-images.githubusercontent.com/30603497/274387208-84982d65-7bfa-4d33-b749-3fcb03b3688f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzQzODcyMDgtODQ5ODJkNjUtN2JmYS00ZDMzLWI3NDktM2ZjYjAzYjM2ODhmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJjODU5M2Y2YWI2OWU4NTMwNDA2YWNhMjQ2OTI0MjFlODk0OTNkMDZkODNiYjA3MjJlOGQ3Yjk4YzkxOWM3ZDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.leGUdHkG3MjI9FcpYyKIgUgdSVD6W6qtddfFvnR1jlA)
- Choosing an Identity Solution: Identity vs OIDC (Read it!)
- Blazor OIDC with Aspire Example
- ASP.NET Core Identity system is designed to authenticate a single web application
-
Installed ef tool
dotnet tool update --global dotnet-ef --prerelease
-
I used Rider to create the project:
Hit Create
-
I ran the migrations
dotnet ef database update
-
Added some missing middleware not included in the template
-
Launched the app, created a new user and signed right in.
-
I used Rider to create the project
-
Added API Key authentication to it. Take a look at the code to see how I implemented it. I referenced mostly this and this.
-
The Logout doesn't work:
Click
Logout
on the bottom left.You'll get this error and the user will be never logged out.
-
Lot of errors show up. Could be a bug in Rider. (The app runs fine though).
In the client project, I setup the ProtectedWebAPI Url and ApiKey in appsettings.json and used that info in Program.cs to call the API.
appsettings.json:
![image](https://private-user-images.githubusercontent.com/30603497/274390708-f8a99aa4-6768-447b-bc4c-e9752d1e896b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzQzOTA3MDgtZjhhOTlhYTQtNjc2OC00NDdiLWJjNGMtZTk3NTJkMWU4OTZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWViOWVjMWRlNzUxZjkwOWI2Y2Y1NjIzZWMxMTNjNzIwNGUyZWNjY2YzODU0NmRmNTRlMTQzMDM5Zjc2MGQ1NWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hExb_gKXqL8Myr0mAA-kK8Wd-A55fVNWI6bZ_iXGFgI)
Program.cs
![image](https://private-user-images.githubusercontent.com/30603497/274390779-81f7e84a-4360-45a1-90d7-360b28c003b6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzQzOTA3NzktODFmN2U4NGEtNDM2MC00NWExLTkwZDctMzYwYjI4YzAwM2I2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwOWY4NmU1ZGY4MDliMjZjNDE0MTkzNGIwMjY1YzUxZWFjZWU3MmEwZjQ0NDU3NDA1MTQ5NGZhNmE3NDRhNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.EW_Bzyof1tTR4-w3Kt0-8NObDLNOPC5NuMCQEocZ81w)
WeatherForecastService.cs:
![image](https://private-user-images.githubusercontent.com/30603497/274390998-b518a68a-a07f-417b-a9fb-dac19ea7e94f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzQzOTA5OTgtYjUxOGE2OGEtYTA3Zi00MTdiLWE5ZmItZGFjMTllYTdlOTRmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI5ZjlmYWQ5Y2U4N2I3YWRkYzAxNTc1OGM0YzlhOTU5MWEzYjA3NGFiNjQxNTYwMDVmYjJiNzIzZTJkMzdlZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Wj4cq-UxlxcaZsMGbG9hV8piYoojEsJO7Z17hRJ8W-4)
Add Microsoft Authentication to your app. Reference.
![image](https://private-user-images.githubusercontent.com/30603497/275102431-ecb5b07c-63d1-4dd0-9eff-2bf0faa4eb42.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUxMDI0MzEtZWNiNWIwN2MtNjNkMS00ZGQwLTllZmYtMmJmMGZhYTRlYjQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjZjRiNjVmYWIyNTVkNWQ2YjRmYmUzYzZmNWEzNDIxMTMxODUxODU3MmRhMDQ2MTUzYTUxMGQ4YzY3NGQ5YjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.PclPLP8sppYbUFFR1hDcWDcITd6Gty1ZRmsWNRd-fbA)
Store the secret in user-secrets
. Store ClientId in appsettings.json.
![image](https://private-user-images.githubusercontent.com/30603497/275104562-7fe8b6ed-1e3e-4ee6-96a1-b3a1a343b1b2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUxMDQ1NjItN2ZlOGI2ZWQtMWUzZS00ZWU2LTk2YTEtYjNhMWEzNDNiMWIyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE2ZmYxMGVkMDc5MDJkOGYyYjA0ZDY4MTZmMTA0MTk0ODllOGVmODFkZmZiYTUwY2Q2YWYxNDk0OGI5ZGQzNjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Gr1HnAHmM406XdwmFEKVIsFG1z0kqzptkILQbFYc8Kc)
![image](https://private-user-images.githubusercontent.com/30603497/275106139-076100a7-876b-43aa-9757-09deac4c11ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUxMDYxMzktMDc2MTAwYTctODc2Yi00M2FhLTk3NTctMDlkZWFjNGMxMWVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhZDc1NzRhMjQ3ODNhMDc3MjAzOGMxMjQ3MmY0MTZmMjhjZWFiMjRlOGVmODZmNDRjYjY3MmE0Y2ZmZDUyNmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.6ewx6GSkcP6CTYrawBrGY0NvBhvr4ANAkoNGW1F5L94)
![image](https://private-user-images.githubusercontent.com/30603497/275107886-930f4184-26f4-4fdb-a6e1-ca7e84790eb8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUxMDc4ODYtOTMwZjQxODQtMjZmNC00ZmRiLWE2ZTEtY2E3ZTg0NzkwZWI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAxMDI3YjkxYzMzYjA4Zjg4YTE5NzRmNzQ2MTFkMDM2MDc2YWZjNjM1MzJmMDUyMjIzOGMzMzA2NmQ0YjA4NTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.NjRJs68A4MKVhb5n7JoccU6vrajIfTpyCVxQODoWxZA)
The services are setup at the last line of MicrosoftAccountExtensions
where there's a call to .AddOAuth
.
Here you can see the MicrosoftAccountHandler
.
![image](https://private-user-images.githubusercontent.com/30603497/275283214-f93e19a0-e5b7-4380-8497-9a75b7e7c088.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyODMyMTQtZjkzZTE5YTAtZTViNy00MzgwLTg0OTctOWE3NWI3ZTdjMDg4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRhZmE2ZjUxMTJjZGRlNWE4NTEwM2Q2MGI5ZDdhYjlmOWZlZDRiNTBiY2U0NmY4MDNjOWJkMjRmMDkyMzMxNjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.V_MYZ_N35AiOhylUE1IMMI7G7G_McJlfWigrg4Mt73I)
To see how the above claims were fetched, you can see it in the MicrosoftAccountOptions
class added from the package. Here you can see that it had asked for the scope of user.read
and Claims were mapped this way:
![image](https://private-user-images.githubusercontent.com/30603497/275279473-82aa93ac-f81f-4c36-988e-9c9228c2512c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyNzk0NzMtODJhYTkzYWMtZjgxZi00YzM2LTk4OGUtOWM5MjI4YzI1MTJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTliOWYyNzZiNTFhNzY4NzIyOWQwYWVhNjJjYjMxNTExZGY0YjM3NjU3NWE3MGRjNmZjZTM4OWY0NjE5MzRlMWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2fdZNnyIl8w2SGwcFgk6VdhbVKnmQ6_a74nDfcM2OzA)
Command + Click on .AddMicrosoftAccount
method:
![image](https://private-user-images.githubusercontent.com/30603497/275282669-ef6ff0ff-9b6b-43e0-a39d-28ea90500e8f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyODI2NjktZWY2ZmYwZmYtOWI2Yi00M2UwLWEzOWQtMjhlYTkwNTAwZThmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmYzc1ODNiZjEyMmJkZjljMmVhMzY4YjIxOTgzY2U1ZmRjODBhMGUyMGZjMDY0MzliNTFhYzdkNzM1MTU5ZGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.9DOqoTK43N1hstE-YeYZIiO5Ds7ptce9S-gh8xLQT7w)
Check what AuthenticationScheme
was used:
![image](https://private-user-images.githubusercontent.com/30603497/275282710-674d6247-cb1c-4e43-9816-e4d125b7a792.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyODI3MTAtNjc0ZDYyNDctY2IxYy00ZTQzLTk4MTYtZTRkMTI1YjdhNzkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMzY2ZhNjAyOTI4Y2I3ODI4NjY1MDMxM2M1MzAzYWE3YTJiM2EyOTY3NTg2YTcwMTI3MDVkODY3MGYxNjc0MjkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Pqh7RJZzV_115ta9SW6yYR3wexjMrttNvrq_FuY7cfo)
By going to MicrosoftAccountDefaults
:
![image](https://private-user-images.githubusercontent.com/30603497/275282759-fdbe90fb-286c-46c1-8d2b-0e07f4015a49.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyODI3NTktZmRiZTkwZmItMjg2Yy00NmMxLThkMmItMGUwN2Y0MDE1YTQ5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlkN2ExZDBkZjhkYTdkZjJiNzNkOWYyODg4ZjRiY2ViYzdmNDE0ZDJiM2FjMjE5YjI2MzBjNDFjMGY3NzA1OTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.uxuu-0Qdt1PtIuCuBBJAbsxOfMzDNC0_sjD6XmmYGLI)
You can see AuthenticationScheme
used was "Microsoft"
and also see the 3 most important endpoints in OAuth: AuthorizationEndpoint
, TokenEndpoint
and UserInformationEndpoint
.
Add GitHub authentication to your app. Reference.
![image](https://private-user-images.githubusercontent.com/30603497/275110918-b0a2fc52-b8a5-4e63-8b20-a18944848b64.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUxMTA5MTgtYjBhMmZjNTItYjhhNS00ZTYzLThiMjAtYTE4OTQ0ODQ4YjY0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIyNGI2ODgyZmM2N2Y5ZTQ5NmM0ZGI0ZjA1NjQ2NjdjZGMyYTQ0NTczNDg1YTY1NWZkZjkwNTBkYWY3MTRkNWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.f1N1f1POkcYJZUB-98yfgaYsQvBxJoWes07rshbN6Eo)
Grab clientid
and clientsecret
.
Go to GitHub's OAuth docs to find 3 important endpoints as part of OAuth: Authorize, Token and User endpoints.Reference.
-
Authorize
After the user is logged in, GitHub sends us the one time code (that can be used to exchange for a token) to the redirect url that we set during registration.
https://localhost:7074/signin-github
-
Token
-
User Information endpoint to get user info
![image](https://private-user-images.githubusercontent.com/30603497/275343796-4dbaf4b6-b43b-4412-9be3-bd09e6dd3089.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDM3OTYtNGRiYWY0YjYtYjQzYi00NDEyLTliZTMtYmQwOWU2ZGQzMDg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhYWYzNzA2N2MzNDBiYzhmNDY5NjU3NTZjN2FhZGMxOGY1ZjA1MGYzYjY3Y2E1OTI3YTJlOWI5MzQ4ZWFiNzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hGL_Gi8PQtl6B47vDybzjxaNdGDm0sctQCTZJKOLPGM)
Just look at the code.
AuthN and AuthZ Basics Reference.
app.UseRouting()
: URL is matched to the endpoint.
app.UseEndpoints()
: Actual endpoints are registered.
![image](https://private-user-images.githubusercontent.com/30603497/275695317-a605b6d9-173e-41e6-b0c2-1fa166347ebc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzU2OTUzMTctYTYwNWI2ZDktMTczZS00MWU2LWIwYzItMWZhMTY2MzQ3ZWJjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYxNDEzNjk1ZmVjZDUzNWIyNmQ5MzAwNjI4MzQ4NjJlMzhjOTFiZWViNTYzYTQxYmQxNjYzMTdhYmRjODdhNGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TSVsNynvQ4D1RtkXDFMfScN2j8jY7Tn3xfmHil_Cvj0)
This is what cookie contains
![image](https://private-user-images.githubusercontent.com/30603497/275687860-63622179-0729-4005-94b2-bb182dcc9c6d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzU2ODc4NjAtNjM2MjIxNzktMDcyOS00MDA1LTk0YjItYmIxODJkY2M5YzZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI3MGI1MmJkNmE3ODlhYmEyZGEyZTI0ZDQzMWUwYTQ3OGIzYWJmNGE3ZjViMjE1Y2RjMTBjNTllNDg5YmI2Y2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.bgXNvJEDjA6ZOzn7EPVRbtvtR2RH6_m-ZmV9AB2ZyWw)
You can retrieve those Items
from AuthenticateResult
.AuthenticationProperties
.Items
:
![image](https://private-user-images.githubusercontent.com/30603497/278843243-6fba6417-9d36-46c3-aca6-1e37ada61703.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDMyNDMtNmZiYTY0MTctOWQzNi00NmMzLWFjYTYtMWUzN2FkYTYxNzAzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThlYWI1ZjFkYWMyZjBlMDZhZDMyYTBjZGIyZmQ1MDRkYzQ4NGM3MzJjMGNjZDUzNGQ5NGZkNjU0MDNlYTk5ZTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lP8WxOYKSjQY9RGNb3oAmYtuUpiF7K0GKGWji4N6HTs)
It is handled by RemoteAuthenticationHandler
.
![image](https://private-user-images.githubusercontent.com/30603497/275708723-9560406a-76b6-4b84-8631-3cdf9938810c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzU3MDg3MjMtOTU2MDQwNmEtNzZiNi00Yjg0LTg2MzEtM2NkZjk5Mzg4MTBjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI0NTAxYmEzOTg1NGNjMzdmOTMwNDZiMTc0NjE1YmI4OTYzOGNmMWFkZDc3NzBjY2JhODc0NjUwOTlmNjBhMzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IVg__391cxJo6gzPjUV3fyCPTMNfChtrCSgVawmmxA0)
Google, Facebook, Twitter, Microsoft Account etc
OpenID connect, WS-Federation, SAML etc.
Every time you navigate to ANY page in the app, the Authentication
middleware runs (It's middleware duh!).
It's the bit that's inside app.UseAuthentication
:
![image](https://private-user-images.githubusercontent.com/30603497/275292859-8c89eac8-2b5f-4ae0-8840-94da5bd0e3bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTI4NTktOGM4OWVhYzgtMmI1Zi00YWUwLTg4NDAtOTRkYTViZDBlM2JkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdiMTA0OGNiY2M5ZGIxYzkzY2E1YjEzNjlkZDA5NmY5ODQwMDBiMzJkZGI1NTNmMGE0YTBlNmE2YjIxMGE4N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.il1nxDKLlxqgr9f7Sd9_pAPb6DHbXobvFiLMdsZCPIQ)
See how IAuthenticationHandler
looks like:
![image](https://private-user-images.githubusercontent.com/30603497/275287437-01b3b931-2628-4f28-a25a-3143f2f34503.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyODc0MzctMDFiM2I5MzEtMjYyOC00ZjI4LWEyNWEtMzE0M2YyZjM0NTAzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTg2NjJmMDA0MzE5NDM1MGMyMmJmNWVhZTE3ODJjM2JjY2Q5NDIzZDZkZWU3OTk3ZWMwZDE5MTVkZWU2ZTM4ZjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.nEo5ZHUWzMtX5sw2iGRBTmVufxT2Nu6Km5uU7TIcXvs)
See how IAuthenticationRequestHandler
looks like (this is relevant in var handler = await handlers.GetHandlerAsync(context, scheme.Name) as IAuthenticationRequestHandler;
line shown below):
![image](https://private-user-images.githubusercontent.com/30603497/275344481-958e94de-0abc-4d23-90e8-4272edde5a6a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDQ0ODEtOTU4ZTk0ZGUtMGFiYy00ZDIzLTkwZTgtNDI3MmVkZGU1YTZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFlNjgwMGI3Y2Y5ZTZhYWMwMTZhYzdjMWQ3Y2U1ODAwYjAyNWEwM2U2MWIzOWUyOWNjNzgyYTYxNjE4Nzg5OWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2cz6xs-oJ1M54vPq6beNkzHeR_zd6CFGtf8Ivt36UvI)
I have setup Microsoft and Github (OAuth) authentication, so I've got 2 handlers now:
![image](https://private-user-images.githubusercontent.com/30603497/275292903-99bbc7d8-27c2-4c5f-87cd-72c7fe71ef84.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTI5MDMtOTliYmM3ZDgtMjdjMi00YzVmLTg3Y2QtNzJjN2ZlNzFlZjg0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE3YmFmMTgwNzk5ODYyYjI0NjY0ZTIzYTIyM2E3NzllODdmMjEyMDQ2NzIxOTBhYTI2MGU2MTRjNmQxMDZjNDYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hd06koefnVJTrRIj1Ul8gXnkc7jxT7WwMiwXYiAHaos)
Those 2 handlers come from the service registration section:
![image](https://private-user-images.githubusercontent.com/30603497/275292937-dac16155-7c29-413c-8f5b-9dac327dc2de.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTI5MzctZGFjMTYxNTUtN2MyOS00MTNjLThmNWItOWRhYzMyN2RjMmRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQyZmZjNmQyODA3ZDVjYWRhNjliMjJhMzQzNGFlZTYzYWM3YjE4ZWJmYTUxNWU2Nzg1MjYyNWRhZWE4YTI2N2EmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7ekMhl8DhydtWvPBTPISE16DVipGYzcxxE9aIxQUAVQ)
The middleware determines if it should handle auth request on those handlers (using IAuthenticationRequestHandler.HandleRequestAsync
).
![image](https://private-user-images.githubusercontent.com/30603497/275338830-6daaf501-1804-4f26-807c-5eee61705fe1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzMzg4MzAtNmRhYWY1MDEtMTgwNC00ZjI2LTgwN2MtNWVlZTYxNzA1ZmUxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFhZWRkM2JmNTEzOTQxMjBjNDRjMmQ0NzA0MDZkNzk3MmVkYjcyZmY0MjY0Y2Y5NTE3YmRmMjc3MmY1MTNiZTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.4C5eZD7bjoxd0zG_WUEyhvBtX9_tR_4cjL9Lf7zTWNA)
For eg: For my case (Microsoft, GitHub handlers), it's determined by HandleRequestAsync()
in RemoteAuthenticationHandler.cs
:
![image](https://private-user-images.githubusercontent.com/30603497/275293117-c2844e22-93ec-474c-9b5e-fed5a897d81b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTMxMTctYzI4NDRlMjItOTNlYy00NzRjLTliNWUtZmVkNWE4OTdkODFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI2NTU4OTE3MzdjMmVlY2NhNDAwZTc4MWZkMjkwZTQ1NjZhMjkwM2RkNWM1NmE2Y2IwYzk4MzJkYzgzMTQxY2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.fgsZE5OG1QfPVMiPAvsxCxdO9A3DGmsZQw239DX3T5g)
Since, I'm going to "/counter" page now, the HandleRequestAsync
method short circuits.
Default AuthenticationScheme is whatever I setup in .AddAuthentication
:
![image](https://private-user-images.githubusercontent.com/30603497/275293249-6019d4bb-c0a0-430b-8bcf-bc7bee007bbd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTMyNDktNjAxOWQ0YmItYzBhMC00MzBiLThiY2YtYmM3YmVlMDA3YmJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4OTFhMDFmZTg2OTFhMjM2ZGU0OGYyZGIxZmEwZDliNDBjOThjZTM1NDkwZmI4MjJjN2MwMzI0NTcxNjQ5NjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7jPbxlWxW5X6-WZmBWBb0m0Z5sHmSfWDXUWuyiMwZcY)
Using the default authentication scheme, it tries to authenticate the current request. If it succeeds, you get .User
in the HttpContext.
![image](https://private-user-images.githubusercontent.com/30603497/275293783-e018d9a7-88cd-4443-bd18-b77d69da11bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUyOTM3ODMtZTAxOGQ5YTctODhjZC00NDQzLWJkMTgtYjc3ZDY5ZGExMWJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFiNDM1OTkxZDZiYmY5Yjk0MzA1NWMwZWU3OTZiMzk2N2EwMDJmMDBlY2FiOTVkNDk4NGZiZjU2MGE3N2Q1ZTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cjGGcp9701-IEPPYkI9lauuTmJxIyvOOJOPTzbBMnEU)
To view the handler for your default auth scheme, navigate from here:
![image](https://private-user-images.githubusercontent.com/30603497/275341892-c4d0281d-ee29-4886-90ef-f923537385f6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDE4OTItYzRkMDI4MWQtZWUyOS00ODg2LTkwZWYtZjkyMzUzNzM4NWY2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwMGU3MWRkZmQxYWUzNjk3NzY1ZTEzZjUxMmQ1MmVmODAzNDc2NWI5NDk4NmY1NTQ2MTVkOTQ2NWZmYTJhYzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.yyOFfS97MEefAUTeWcuqIe3hYNrB_I1Hui-DGNqAi7o)
To here:
![image](https://private-user-images.githubusercontent.com/30603497/275341922-a358222d-cc17-4d80-9a1f-016f35cc496e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDE5MjItYTM1ODIyMmQtY2MxNy00ZDgwLTlhMWYtMDE2ZjM1Y2M0OTZlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFjZmY5MDc0NTI2MTYzNTQ3NzlmNDVjOGI1YzU1N2I0NzkwOWU4YjQwZjgyMmMzNWM2OTNmNTc5ODc1ODdmYzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.xx8PnUAYW0uiS3LNvEoz1aViq8n19HUpRb2DjKRF_A0)
To here:
![image](https://private-user-images.githubusercontent.com/30603497/275341951-d94e3e07-8435-4c39-83e9-70ef66b7756b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDE5NTEtZDk0ZTNlMDctODQzNS00YzM5LTgzZTktNzBlZjY2Yjc3NTZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE2OTY2M2FmNzg2MDVjODUwMDhhYjI3MDY4ZDYyOWU5NDUzZjE3YjQ3NTU2YzBlYjY1NWM3YzBmMzJkMjQ2MjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._fwTRkhL8jGWeb6mJLoJ6U2gc7HSs-SmOFdTjvxlHZY)
To here:
![image](https://private-user-images.githubusercontent.com/30603497/275341977-3e122c7a-0322-4b8b-8bd0-042a56f09b2b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDE5NzctM2UxMjJjN2EtMDMyMi00YjhiLThiZDAtMDQyYTU2ZjA5YjJiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEzMDZkMDE2OWJjMGUxODQ1YmY5NzQ4MWE5NjQ2ODg0NzVkZjA2NTY4ZTJhZmU1M2ZiZGZmY2YzZTdiNTM2OGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MIG6gD70IaUAbm27ppGwhpa9OSu1udlysaAnAbnKUGo)
To finally here:
![image](https://private-user-images.githubusercontent.com/30603497/275342011-ec95dcf2-9209-4801-a89d-2aab2f50428c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDIwMTEtZWM5NWRjZjItOTIwOS00ODAxLWE4OWQtMmFhYjJmNTA0MjhjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFkNWUyOTFkYTg2YzUxM2Y1ZTU0ZjkxY2I0ODE2Y2Q3MTM4N2YxMzdiN2I2NWRmMTc0MjU5Y2VmM2VkNzVlMmMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JYFyZx74kQUMt-kVnta-SQ3Ixefq8_iYCq0CiWtpXFk)
Here you can see that this service has Schemes, Handlers etc. to authenticate a request.
Now let's get back to see how this line in AuthenticationMiddleware.cs
executes:
![image](https://private-user-images.githubusercontent.com/30603497/275342128-230d9e13-1e78-4892-9ff3-8877a10b574b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDIxMjgtMjMwZDllMTMtMWU3OC00ODkyLTlmZjMtODg3N2ExMGI1NzRiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzMTg0MzFlNzc2MDIyN2I1ZTUwY2E1ZGVmNWU1MjgzZmZjNmM5ZDQwNjUxYmRjOTg0Yjk0NjRlNDkxNDZhMDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.cHwx20iqQUl960QJjX48FqoBjTz0QYyWVss0YXSVAZU)
It just calls .AuthenticateAsync
on the AuthenticationService
:
![image](https://private-user-images.githubusercontent.com/30603497/275342149-c11a1bbe-131d-4777-98b3-9910f34cdfba.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDIxNDktYzExYTFiYmUtMTMxZC00Nzc3LTk4YjMtOTkxMGYzNGNkZmJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWMxYjM4ZTQ3YjRjODNmY2I4M2QzMjNlZTA3MjllNjNmZGFkZjMxNTUyOGZiN2QwMDhkYzI3MWMxNmMxNTUyZjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GJ-XGajbIN3TCIu9T3kbHk9mHNEF86FUAkMXtccmc2w)
See the SchemeName and Handler:
![image](https://private-user-images.githubusercontent.com/30603497/275342609-d7220f34-d95e-437b-8fe6-ed7c2be51555.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDI2MDktZDcyMjBmMzQtZDk1ZS00MzdiLThmZTYtZWQ3YzJiZTUxNTU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmN2RhYzFmY2YwZTE0ZDgzMWYxM2U3OGRhYmQxMDdlYzFkMTdlMjhiOWRlNDlkMTgxOGUyMTAzYmQ0OTMxNzMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.elm0iSaESybgSAecB12VhGdaH-9k_1hh0V_JkCa4lWI)
Now we get into AuthenticateService
's AuthenticateAsync
method:
![image](https://private-user-images.githubusercontent.com/30603497/275342712-5b4e3109-3aac-4030-b583-129f18ab6295.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDI3MTItNWI0ZTMxMDktM2FhYy00MDMwLWI1ODMtMTI5ZjE4YWI2Mjk1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjMWY2YzYyMDRjYzY5ZmYwMDhkMGIzOTc1NzEzNmE3MjQ2N2E5NjVhMTNiZWZhN2IyMTNiMjExMjc1NTNkNjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.URuR-xpwQqNgij3dV0Z38pxMXk2rxtf_YYPfT_pwoUc)
Then into AuthenticationHandler
's AuthenticateAsync
method:
![image](https://private-user-images.githubusercontent.com/30603497/275342965-360f549f-e8a6-400e-aebc-346496e29b9f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDI5NjUtMzYwZjU0OWYtZThhNi00MDBlLWFlYmMtMzQ2NDk2ZTI5YjlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWY0NDlhNTNiODU1NmY1ODdlNjE4ZDQ1YmE4ZTBkNmI5MDVkOWI0NjM5YjQ0OTFhNTkxYjBiZDI1MmNkNDJiZDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Rjg6eAOAzIKTQpSL8bRzLqOZ_5RGT32dUjJN5F4RFCk)
Then into AuthenticationHandler
's HandleAuthenticateOnceAsync
method:
![image](https://private-user-images.githubusercontent.com/30603497/275343069-2d5fb0e8-a0ff-4826-b38a-0d44b87f0f67.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDMwNjktMmQ1ZmIwZTgtYTBmZi00ODI2LWIzOGEtMGQ0NGI4N2YwZjY3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ4YTQ2NDNmYTU4MGM0N2IzODRjYTFmYmJmYzc3YzMyN2EwZWM2ZGIzYjc3NzVkNTdlZmI5ZjdiNGFkMjQ1MmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.EBanSqR-W4TcYpJAIa1VrK9DyDdtpODkJ1h6bV7-CdM)
Then into AuthenticationHandler
's HandleAuthenticateAsync
method:
![image](https://private-user-images.githubusercontent.com/30603497/275343145-00c8d5d7-062c-4266-8fb9-4d66c5c5e52d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDMxNDUtMDBjOGQ1ZDctMDYyYy00MjY2LThmYjktNGQ2NmM1YzVlNTJkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWViNzY2YTE3MzFmOTBhNWZkZGQ1ZTY3ZTAyMDdhYTE1ZTdiZDExMjA2NGU1ZjBlNTI5OGI4N2RmNWEzY2IzNDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.SYe0Ex-J0yCbRBdr0P77DRFyz3xDD_buyEH4szbVA6c)
It's an abstract method that is implemented in a class that derives it, CookieAuthenticationHandler
in this case, so we end up here:
![image](https://private-user-images.githubusercontent.com/30603497/275343291-b91dede3-889a-431c-b586-1de877bb1ad8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDMyOTEtYjkxZGVkZTMtODg5YS00MzFjLWI1ODYtMWRlODc3YmIxYWQ4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFiMjliZDRmY2M0YmVjYmYxYzk5YzBhZGE1MjgyYTAwOTE5NWMwYjlkZGM5OWFjYTFjMmJjMTExOTYxNjA2MTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.b82hBj6R9Sd-X9wZTpKuSQ8H-0XliBBV_BQn-zum5jg)
Then we finally get this result:
![image](https://private-user-images.githubusercontent.com/30603497/275343415-cf863f30-b60b-4605-809f-c653cab8b4da.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDM0MTUtY2Y4NjNmMzAtYjYwYi00NjA1LTgwOWYtYzY1M2NhYjhiNGRhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc2MTIxOWFlMDhhNWEzNzVmYzZkYjAzYzdiNjE4NWMxNDRiNmNkMDA3YzFlNDM3YzZhNTdmZTUwN2I0NTBhMWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.EUfpg5pxxB4784xkjdA0rAOtOjmdBCAK2hpjgqyjBoM)
The schemes the app has:
![image](https://private-user-images.githubusercontent.com/30603497/277503300-36b17dc7-1a95-4cbe-98a7-b5bfd6e140bf.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDMzMDAtMzZiMTdkYzctMWE5NS00Y2JlLTk4YTctYjViZmQ2ZTE0MGJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA2ZWUzODIxYzIzODhmNzFhNjkzZDAyYzVmMzNiN2U4ZGViNDcxMjE3MWE0NDhhNzkwZjczNDFiYTI1ZTY1YWMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.xZmYmFkZZRhTmWTwH80bZ2wLHsVGdbweHvuaLUR8rD8)
ExternalLoginPicker.razor
shows the external logins:
![image](https://private-user-images.githubusercontent.com/30603497/277503648-c6b90469-acf2-4317-b0d1-1e44ca7ce5ab.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDM2NDgtYzZiOTA0NjktYWNmMi00MzE3LWIwZDEtMWU0NGNhN2NlNWFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRkN2RjNjlkZjgwMDhkMmIyMjE1YzU4YTMyNTgyZDAzM2RmMmM1OGFlZGQ5NmQwMDI5ODE0M2E5ZWRiNzQ5YTkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GDc2Mzk2o85C8sPyiqxyQep96TwlNKWHhfeGoD_bZAA)
![image](https://private-user-images.githubusercontent.com/30603497/275347776-917e57cb-8608-433d-b6d0-3de029224c29.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzUzNDc3NzYtOTE3ZTU3Y2ItODYwOC00MzNkLWI2ZDAtM2RlMDI5MjI0YzI5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWRlMTU4Mjc3MGUxOWI5ZDU4YjEzNmJmNjcwZDBmOTY3YzNhYTE0ODljOTBlNjZlNzdmOTEyYTBhMGUzOWY0ZGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.DRo7j2I7KFIRcMJHPhkYgfapomwrljCRn-OMsN8jU1I)
This will call the POST endpoint:
![image](https://private-user-images.githubusercontent.com/30603497/277504359-9b59d135-20b7-4400-bce6-8f917add9f66.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDQzNTktOWI1OWQxMzUtMjBiNy00NDAwLWJjZTYtOGY5MTdhZGQ5ZjY2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNhZTEzZWU3MWVmMmQ3NTRlMzEwN2MyYTUyYWU3YWY4YTMyMTRiMTgxNjFlOTNjZjM5N2Q5NmI3NDExMTJkNGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.SeL92xJjgzdTmgSGYc8pH_rY88dWN3oktQLi3PSKni0)
/Account/PerformExternalLogin
in Identity/Extensions/IdentityComponentsEndpointRouteBuilderExtensions.cs
This is where I want GitHub to redirect me after completing authentication:
![image](https://private-user-images.githubusercontent.com/30603497/277505425-183c5061-7d9e-4d91-923c-f2ac911bb891.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDU0MjUtMTgzYzUwNjEtN2Q5ZS00ZDkxLTkyM2MtZjJhYzkxMWJiODkxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ1ODExYjdiNDNhY2JkOGVmZGQ5YWFlZWE0YzNhMTk3MmY5MDYzMjNhYTk3Y2MxZjI0ODcxZGVhY2FlNDEwODgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.l5Iu_psXZnSi4lN_ryCexVeH1tq2HUbXO55tL6aEf5I)
Use properties
to preserve data between Challenge phase and Callback phase
![image](https://private-user-images.githubusercontent.com/30603497/277505663-1d5b1e07-eecd-47b2-84b8-7b2687c7f4f8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDU2NjMtMWQ1YjFlMDctZWVjZC00N2IyLTg0YjgtN2IyNjg3YzdmNGY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVlZWJhMDdjNjRiYzk0ZWIxMGRjNjhlNDFmNjIxNmEwNWVlNzQzOTEzOTE3OTMxMmEzZmM3ZTRkYzIxMjZkYTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8hgYxQcGjp1PXHjht8CX_bG6jBDZeS-araUHtDdLm1Y)
![image](https://private-user-images.githubusercontent.com/30603497/277505874-6636b1d2-e371-4546-98b5-560ece855a0b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDU4NzQtNjYzNmIxZDItZTM3MS00NTQ2LTk4YjUtNTYwZWNlODU1YTBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzYzA1Yzg0OTc0NWE5YTA1MGFmNmRkMmQxODZlYjEyYjNhZjMxMzFiNzI5OGViMzI2M2ZlYjBiNzU3ZDRiMGMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.suGos7jbWNisZ3s3Lv5-dmuHGXGusVp9n9QpDYfvZiE)
Now we're in OAuthHandler.cs
![image](https://private-user-images.githubusercontent.com/30603497/277506480-e614aba9-b0ea-41d3-8414-216683697b1a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDY0ODAtZTYxNGFiYTktYjBlYS00MWQzLTg0MTQtMjE2NjgzNjk3YjFhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgzOGFiM2Q3NTRkODYyZWY5MGY0NWRkN2RjNWI4YTJiMzliZDNkNDUzNzZmZTc5ZTkwYTYwOWU5NDU0ZjhjYTgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2KztmiDLYV3NWkKJ18OtDUtf2rZ3PvHc2kGkHYK3mMg)
![image](https://private-user-images.githubusercontent.com/30603497/277506580-cb1144bd-c697-40fb-951d-f6d7c050d3fd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDY1ODAtY2IxMTQ0YmQtYzY5Ny00MGZiLTk1MWQtZjZkN2MwNTBkM2ZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIxYTJkY2RjZThiY2U5NWFmYmNhYzlkNDdlYTIxMDA2ZDY2MmMyOWMwOWQyNDNjM2Q4MWViMmJmZmQzZTRiYjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.bY07QyHZD5-MhTmGOLLj9CchVo1IwnwRcQlaHOu-66E)
https://localhost:7074/Account/PerformExternalLogin
redirects us to GitHub's authorization endpoint:
![image](https://private-user-images.githubusercontent.com/30603497/277507128-50538aa5-0641-434a-ae10-2e206cb08481.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDcxMjgtNTA1MzhhYTUtMDY0MS00MzRhLWFlMTAtMmUyMDZjYjA4NDgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc2ZGEyZDNiY2I0NjA3NGU5MDM5MzE3NGRhMmIyNTE1MmUzNjNjOTJiZWExOTUyMDk4ZDIxMWNhYjM0ZGE2ZDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.YzpXg9nPWLCVIORbpA314vDns46UgbGpmtJFOj9JsJc)
So the app goes to that location:
![image](https://private-user-images.githubusercontent.com/30603497/277507460-6c1de721-730c-4a9b-9212-f1c0d37c5f34.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDc0NjAtNmMxZGU3MjEtNzMwYy00YTliLTkyMTItZjFjMGQzN2M1ZjM0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ0NjRkNzQzMTgxMzRlOTNmNmJlOWViZmMxNTBhOWNiZWEwMDRmYzhhZGJkNTYwMjgxOGNkMDU1ZDJmMmRhZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Vf1_GcvsqBMnU9xJCZ84aZGuDnDQ-Pykf0RBK27R4xI)
At this ppint the user authenicates with GitHub (NOT this app) and the user authorizes this app to fetch user info from GitHub by accepting the consent screen.
User gets redirected with the one time code to the callback url:
![image](https://private-user-images.githubusercontent.com/30603497/277507601-b00ae5cb-8049-4f04-a66a-7028dc05c30e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDc2MDEtYjAwYWU1Y2ItODA0OS00ZjA0LWE2NmEtNzAyOGRjMDVjMzBlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzZDMwNTlkYmIyY2I4NWZhY2Y1MDlkNjJiMzI2NGNmZjFiZjUwNTNmNzQxMjk4YTk2NmU3NDk3NmY3ZmU4OTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.6vttQzi5Fibb_4gPna4q_sTnMmVA6a-q0TMKcWiC1Fc)
![image](https://private-user-images.githubusercontent.com/30603497/278841054-bd2a2f49-ec27-484c-ac78-4c8d2fc1f1fb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDEwNTQtYmQyYTJmNDktZWMyNy00ODRjLWFjNzgtNGM4ZDJmYzFmMWZiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwNzgyMDQ4OWFiMmRjNzE4MDFlMmJmZGJmMjFlZjVkNGMxYzU3YTRkYTk3NmJiZDkyODFmOGMxMTlhNDgyNTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.AthA1M3PPBjqg5wnOHrgpi_4tAGa3pTx4z7RgceV6a0)
OAuthHandler
says "I will" because ShouldHandleRequestAsync()
returns true
as seen in RemoteAuthenticationHandler.cs
:
![image](https://private-user-images.githubusercontent.com/30603497/278840760-418de550-8f9a-489b-b466-5c6e6d065c72.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDA3NjAtNDE4ZGU1NTAtOGY5YS00ODliLWI0NjYtNWM2ZTZkMDY1YzcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5YTgwNTk1YzM3ODYzYTEwNzU1NmI2ODM0MjM2MGE2Yjg5NzhjNmYxYjVkYmYzODZjN2I0NjU4ZWI1OWZlZGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Ir7YbzWNWxqWlwNpgM8lfGdZrPnT26_1Y2liLnw04p0)
When line 87 shown above runs, we end up in OAuthHandler.cs
:
![image](https://private-user-images.githubusercontent.com/30603497/277508722-f8c82466-55ac-4b97-a8ba-533df1165d57.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDg3MjItZjhjODI0NjYtNTVhYy00Yjk3LWE4YmEtNTMzZGYxMTY1ZDU3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY3YTk2Mjk0MzZiMmFkNjk3NDIwMjAxMmU4YzU0OWY1ZDA5OWM2OWRmNmQyMjU4NGY1MzA5N2FlYmUyYTkzMDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iMLmK5D1eEjlCIZGSYdRWWYzU_Qu6H5_uy3fexmgFUE)
The query has code and state.
![image](https://private-user-images.githubusercontent.com/30603497/277508599-e5d61a96-0f32-492a-a095-68ce34382dac.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDg1OTktZTVkNjFhOTYtMGYzMi00OTJhLWEwOTUtNjhjZTM0MzgyZGFjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNiMjUyOGE4ZWMwOWMwNTYwZTRhYTdkN2U4ZWQxYTBhZTg3MzE1MWEzYWU0MGM4MjJkNmJmMzFmYmNmNmFiZDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.eDFc6jQDZN4SNvl4-7Y6wOeV_pjnAG3US6JRXp7SlNI)
The state has redirect url and login provider we set earlier:
![image](https://private-user-images.githubusercontent.com/30603497/277509318-4852f83e-af86-4983-97be-f79352ef52c0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MDkzMTgtNDg1MmY4M2UtYWY4Ni00OTgzLTk3YmUtZjc5MzUyZWY1MmMwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyMjk0NDY1N2EyOTYwZmM1YjI5ODA4M2JmNGFhNjZlNDM2NGE2YmIxMWM4MjVhZTg0YTYxZDA2YmVjMzU0ZTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.dkbihrLwwvlrot_Y5QqwiACjqRF6HjVSHJGB6XJbbVE)
The code is exchanged for the token here:
![image](https://private-user-images.githubusercontent.com/30603497/277510023-51dc3939-bbd1-42e9-9c4f-14b5c0cff9ac.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTAwMjMtNTFkYzM5MzktYmJkMS00MmU5LTljNGYtMTRiNWMwY2ZmOWFjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVmZDAzMWRhZTdhZDE5ZTg5OWQ4OTAxOTU5YzYxNGNkMjAxYzAwM2IzODZlYmFmZTMxMjA3MDRhYjAxYzg4OWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.brG7a0cGFN3EIRjvDnN4YzeLFefeNnik0IadDVad0Ro)
Dummy identity is created:
![image](https://private-user-images.githubusercontent.com/30603497/277510467-3aa27088-72af-4dfd-9549-8c84b5115e72.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTA0NjctM2FhMjcwODgtNzJhZi00ZGZkLTk1NDktOGM4NGI1MTE1ZTcyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIxYjdiMDQxNzJhODczMDY5YzliOTQ3ODQ5ODNhNWNiMTJhNDJiYjMyZTRiZTYwYjJmYmQ2Y2FmMzQyYzQ1MjcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.4YP0u29PPEhSfCaQvDQKNpeyCsyAN9GBI8Bh6ENa_sY)
Towards the end of this method, a ticket is created:
![image](https://private-user-images.githubusercontent.com/30603497/277511368-9482726e-92c9-497f-ae8f-f3821a08e2c6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTEzNjgtOTQ4MjcyNmUtOTJjOS00OTdmLWFlOGYtZjM4MjFhMDhlMmM2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTViMTE2MDgzZDJkMjQ2MzA3M2EzY2Q2N2MzZGEyYTgxMGJlZmQ5MGJkZDFhZDBiOWIzNTM0MGZmZGIwZGMzNmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.TQg66G7aKcycr7qeLjlfu-TnshNBXPEKw9VM-t_Dn5o)
By calling this callback:
![image](https://private-user-images.githubusercontent.com/30603497/277511734-d5a31a96-1eee-42b3-a171-cff98e00b9eb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTE3MzQtZDVhMzFhOTYtMWVlZS00MmIzLWExNzEtY2ZmOThlMDBiOWViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQwYzgxOGJkMWFmNGExMmU5Y2FhZGE3NGEyZmMxYWRmYWY1YjIxMzM2YWNiMTk0N2NiMDhjNThkNWQ0ZWU0MjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.vQZu56yQPnfEAjVJBGT2OokIIY3T3HnzJbaH8ug9H9w)
Now we're back in RemoteAuthenticationHandler.cs
.
Inside HandleRequestAsync()
, we set which scheme produced this identity:
![image](https://private-user-images.githubusercontent.com/30603497/277512191-ded03b88-3c8a-4ab2-bd51-268087cdfa26.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTIxOTEtZGVkMDNiODgtM2M4YS00YWIyLWJkNTEtMjY4MDg3Y2RmYTI2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ5YWJhMjJjYjU5NzQyNjI0Y2NjZjFmMzA4MTY4MWMwY2E2NWE0MWRkZjQ0OTExZjZiODM0ZDA2MDg3MWRjYzEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._jRzPWi45MaE3z6xhM9gLA__F68BwfuTrgGpQB2BXSE)
In RemoteAuthenticationHandler.cs
![image](https://private-user-images.githubusercontent.com/30603497/277512385-a7b6a17e-93c6-437e-8172-3cc725d8d117.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTIzODUtYTdiNmExN2UtOTNjNi00MzdlLTgxNzItM2NjNzI1ZDhkMTE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI2NmYwYmExZjRhYWRlYWQyNjIxMjdjN2NjN2FhODJhN2RmNzFhN2FkOGQ3ZTA5N2JhNmIyMGZhZTdmYjMxZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.778gLSmRVRoOvbPlGmDdq_A11uzy9OZ68dAmADzC2FU)
The Principal
looks like this:
![image](https://private-user-images.githubusercontent.com/30603497/277512592-efdedcb0-6096-4fa7-a64b-1f2d06639284.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTI1OTItZWZkZWRjYjAtNjA5Ni00ZmE3LWE2NGItMWYyZDA2NjM5Mjg0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE1MDU2NjkxMWJlMTc0MWFiODA0YTg4MWY2ZjU5OWY1OTBlM2ViNmE5NGQzYjFmOWVkMDM1ZmViMjI1NTgzZDkmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.FXMt8pYp6rRtZueUG_2CXLWAXJvFxUVdBhc4Ahh_9RQ)
And the properties:
![image](https://private-user-images.githubusercontent.com/30603497/277512669-a7bd09e9-05fb-45d0-98e4-103c85f26f2e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTI2NjktYTdiZDA5ZTktMDVmYi00NWQwLTk4ZTQtMTAzYzg1ZjI2ZjJlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzNzVhZjRhZWMxNmQ0Y2JjY2VjZmI4ZjgwODVkYmRlMTU2Njc3ZTU2MDVjYTYzZmFjNzExMmQwODRjNTdkMjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jNVDkM70YXGk-XU-zxSvGxrQKyh2zjZHmMZWOIdgJEk)
Now we're in CookieAuthenticationHandler.cs
's HandleSignInAsync
method:
![image](https://private-user-images.githubusercontent.com/30603497/277513438-53828fd4-b44a-41f8-93fd-8adba174305b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTM0MzgtNTM4MjhmZDQtYjQ0YS00MWY4LTkzZmQtOGFkYmExNzQzMDViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlNjhmZjBlNWJjY2I0MDI3NmU5ZjZiNTU2NjAxMTBjOGEyZTRkN2Y1ZDYwZWFiOWQ1NTdkZmYxYjI5MWYxNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.J7Bzge_R2sylOCzX5pGMYGU4TmKy0NPccS4h7oX2ux0)
A new ticket is created:
![image](https://private-user-images.githubusercontent.com/30603497/277513620-62d52eda-c8be-4219-984a-b71f6faab16c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTM2MjAtNjJkNTJlZGEtYzhiZS00MjE5LTk4NGEtYjcxZjZmYWFiMTZjLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEzZDZlZTA1MGQxMmJiMGJlNTY0MmRjMzhhYzYxYTQyN2UzNDY3ZjQ3ODg4MGMzZWNjMWY3YWYxOTQ0MDFmMjUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZWwfduybr_5bpi4jscp_lI2REJ3PrUWswYg04Rwvj58)
![image](https://private-user-images.githubusercontent.com/30603497/277513684-abf50c5c-5ea2-4739-8e05-b798d41d05c6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTM2ODQtYWJmNTBjNWMtNWVhMi00NzM5LThlMDUtYjc5OGQ0MWQwNWM2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0YzcxZWUzOWNhOGYwODFkMGFkZTUxMDE1ZWU1NDdkOTE3NjMzZWJmMjU3ZDE4OTViYmJlMjVmYmJlOTA5YWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.OmaO8QVcmiLTM-8MZoWsCv5A4__MqSI7PWlPIfwf-g4)
![image](https://private-user-images.githubusercontent.com/30603497/277513727-5ecc20bb-a5e3-464e-a676-578c37762deb.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTM3MjctNWVjYzIwYmItYTVlMy00NjRlLWE2NzYtNTc4YzM3NzYyZGViLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU5MTRiOWE1ZWFlZmU0ZThkYzAyM2M3ODQzYjQ0Zjc4YTk2Y2M5OWYyNzdiMWUxNjNiMDJiZDE4YTllODUxYWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.UhwTnVc20dHVEx7ny7sHioZYm7I5m3Xl_zE-J9QuGx8)
The method completes:
![image](https://private-user-images.githubusercontent.com/30603497/277514241-799879be-724c-4365-b775-b967b1015f42.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTQyNDEtNzk5ODc5YmUtNzI0Yy00MzY1LWI3NzUtYjk2N2IxMDE1ZjQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5OTA4MzdhMDhkYTY1NjIzMDQ1NWI2NTU3NDg5NWU4YzBiNTE3NGM4NmUwZmEyYzI3NWE0ZmY5MzNmN2VkYWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.undSYRMriG-UvQyJEcHj03ryBYy0o05sFf5VIGb6Bec)
This method also completes:
![image](https://private-user-images.githubusercontent.com/30603497/277514402-691d6e9b-8a80-42b8-9235-b92dffeba3a3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTQ0MDItNjkxZDZlOWItOGE4MC00MmI4LTkyMzUtYjkyZGZmZWJhM2EzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTE2NmVhMzU3ZTQzNWNjZGZiZTdhMDA5OTkxMTIzNmUwNzExMWI4OWFlMTkzMzU0MDUwYzQ1ZWE2YjE0NWViNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.nd6w2NjOcdrVAAAtFwpteK5xEZJWF2eyFW0HhaQUKBo)
Now we're back in RemoteAuthenticationHandler.cs
's HandleRequestAsync()
method and about to get redirected to our original ReturnUri:
![image](https://private-user-images.githubusercontent.com/30603497/277514646-ce59159e-c32d-405f-990b-03612c9c5044.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTQ2NDYtY2U1OTE1OWUtYzMyZC00MDVmLTk5MGItMDM2MTJjOWM1MDQ0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM4YWZkMDIxYTQ5NmU5YjdiY2ZhM2U5OGEwMWI4YmY5MDc4YWY5ZTIwMDU0YTAxODY5YWMwNzY1ZWI5ZTNmNTcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iAXh_wJTPbEJaAX9AX7Xr12d8zSk61RHm9Bdwlg1F8Q)
Now we're redirected with the "External" cookie
![image](https://private-user-images.githubusercontent.com/30603497/277515232-3db98c10-d5d5-4837-b810-a9a389ae8c3a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTUyMzItM2RiOThjMTAtZDVkNS00ODM3LWI4MTAtYTlhMzg5YWU4YzNhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTliMDNmZmY2NDc1ZGZmOGMwMjRhNDI3Njg4NmM3MTU5ZjgxMzM5YzcyNDk1ZWRkOGYyNzYzYjE1OTM1ZWQ5NWYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.ZF0oyJm6npYnkr-9fvwUvXW8G4Vad_TEWzNjFe_nIXY)
Now we're in /Account/ExternalLogin
(In ExternalLogin.razor)
![image](https://private-user-images.githubusercontent.com/30603497/278841169-b19591c8-47c0-4bae-aa83-31dad84c7e47.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDExNjktYjE5NTkxYzgtNDdjMC00YmFlLWFhODMtMzFkYWQ4NGM3ZTQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxOWYzZDcwZmNhYzhkN2NhNzJlOGEyYzFiZDc2ZTQ2MDE3OWNjMDU3MGFkYThhMTgzYTM5ZjgxZDA4ZTdjNjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.aSh8ClsFXShhD1frwjMfFVgq8vIzP0XYeoX_ST5eIiE)
We try to authenticate using "External" cookie to get external user info:
![image](https://private-user-images.githubusercontent.com/30603497/277515775-9ff77a0c-e3e5-4ec8-8c4a-0f5e6e92295a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTU3NzUtOWZmNzdhMGMtZTNlNS00ZWM4LThjNGEtMGY1ZTZlOTIyOTVhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwNWI0NzZlY2NiODQwNjA2YzJjZTY5MmJmNmE1ZjU3MmVlZGU3ZTVhNjVlYjZmYTBlNjJiMTliMjJiZWIxNGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.5moqAgpvZ7X0ohnK0_qTjiLhJDD8n5dhRKwUEOemBqU)
Now we have userinfo:
![image](https://private-user-images.githubusercontent.com/30603497/277519290-e535c97e-68c2-40e7-b87c-c1cee4169963.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTkyOTAtZTUzNWM5N2UtNjhjMi00MGU3LWI4N2MtYzFjZWU0MTY5OTYzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU0YTEzNzFlMjRiZjhmZWUwYWY0NGM2ZWI1MDdiZjZjOTNmMWZhNjIzZDNhYmRkODI4MzgwNGVjZTFhZmExMjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.k77m8vv8MnuUG1gqU08tO9iltYfneq4-ReZSdydjLV8)
![image](https://private-user-images.githubusercontent.com/30603497/277519405-44fce317-969a-4447-ad47-8efd62f17e99.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTk0MDUtNDRmY2UzMTctOTY5YS00NDQ3LWFkNDctOGVmZDYyZjE3ZTk5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc4MWFhMDdiYzhhYWYwMWUwYjlkZTVjNGFjN2UwZmMwYWQ4MDA0MTQzYThkYzY3OTI0ODQwYmQwMjVjNWM0NWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Qb-f3fBtW7WDmG7ETPtDNFgWRzEgItCiVSbGHRqzMtQ)
ProviderKey
is the Id in Github.
Now we go into OnLoginCallbackAsync()
:
![image](https://private-user-images.githubusercontent.com/30603497/278841992-3d043121-946d-44f6-aaa5-f70a9316faa6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDE5OTItM2QwNDMxMjEtOTQ2ZC00NGY2LWFhYTUtZjcwYTkzMTZmYWE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE5Mzk1ZjRkNzdmNDZkMTE4Y2IxNzBlMjFiMzkwNGE1NDNkOTRiNmQyZGRiMWY0YzUwMDI3ZTQ4ZWI1NThjNTQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.2AYIiGtTtxsccV1ewmTtgtok7uZOCy7T4VTFVYjqeqg)
Here:
![image](https://private-user-images.githubusercontent.com/30603497/278842120-f403c022-4976-46ec-a90b-0187b309a244.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDIxMjAtZjQwM2MwMjItNDk3Ni00NmVjLWE5MGItMDE4N2IzMDlhMjQ0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc4MjhmZWU2ODlhZjVmZWMzZWY2NmY5YzEzZTgzZjFlNTQ4MWYyMjllZGM0NTQwMmU4YzIyMGZkZDBjYjliNDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.POdB1ZzuzqIIdc_3Tj_29c9U9aSAExjNLerT6wFLpDg)
Now we get into SignInManager.cs
:
Looks like there's this neat method to get user by loginProvider
(for eg: github) and providerKey
(for eg: 30603497).
![image](https://private-user-images.githubusercontent.com/30603497/278842193-9503fe80-ab4a-4efa-843b-d0fc0cc0120f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDIxOTMtOTUwM2ZlODAtYWI0YS00ZWZhLTg0M2ItZDBmYzBjYzAxMjBmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc1ZDYyNTEzZDFiMDI1MTgxZmQ0Y2ZkNmQ4ODA2ZmQ5ZjYwMWFjNTZhYWI0YTEwYTIzM2NlY2ExYmYxMWNmNTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iKXxRMAij1x9AWNMIMnicamlXv77d0o1HusLc-6bNPE)
Whenever AuthenticateAsync()
method in AuthenticationService.cs
runs AND AuthenticateResult.Succeeded
is true, ClaimsTransformation is run.
![image](https://private-user-images.githubusercontent.com/30603497/277518475-4fe09ea7-7cfd-4a7a-ac8b-f4401b0ff828.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzc1MTg0NzUtNGZlMDllYTctN2NmZC00YTdhLWFjOGItZjQ0MDFiMGZmODI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyNTQ3MGYyM2IxZjVkNzFhYTI1NjU1MjMyZTFjMDQ0NjE3NmNhZDY3ZTFjMzk5YjM1NWFlOWU0NTcwMzdiNmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.WXTAlkMKfyR2Vt3sLwdMGTSQlWMm0EMOOXAcnel_mZ8)
Here:
![image](https://private-user-images.githubusercontent.com/30603497/278840028-fcd8d092-a4a9-4721-8cbd-47e2fbe10dc0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDAwMjgtZmNkOGQwOTItYTRhOS00NzIxLThjYmQtNDdlMmZiZTEwZGMwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTAyODdhZTk4ZmU1MTI0Y2M0ODAyYzcwZjQ4M2M4OTEzODViMjBhZWE3MjY0NTU2MzA2ZjViYTNjYWYzNGFmZDcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.lo7_wAKt0vQgxtucCqi9lFZ7Wis3nUttqSyU_MHlDMo)
The action in the query is this:
![image](https://private-user-images.githubusercontent.com/30603497/278841261-008bb985-d0a1-409a-b738-3fe277cc2fde.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDEyNjEtMDA4YmI5ODUtZDBhMS00MDlhLWI3MzgtM2ZlMjc3Y2MyZmRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUwMjk2MTllNmNjYTc0NzA5YjdmMzU0NTE4NzJlYWIzYjQ0M2IyY2Q5NTA4NDRiNmNjZjJjMzIxNzdiYzFjYmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.m6UF1e8iw5vegTay9YyJHBPETjqsUBIKZD8wDFjSeiQ)
Also notice the user is not authenticated at this point because we haven't successfully authenticated with the default authentication scheme (Identity.Application).
If for some reason, we're not able to get externalLoginInfo
, an error message is passed through the cookie in the redirect to be shown in the UI.
![image](https://private-user-images.githubusercontent.com/30603497/278841548-45b207d1-ad0d-447c-a5aa-e3dd69495ec8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDE1NDgtNDViMjA3ZDEtYWQwZC00NDdjLWE1YWEtZTNkZDY5NDk1ZWM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNlOGM0YjY1MTg0YzVjNWQ3MWUzNjY0M2UxNWJhYTE5OGI0OWU3YzNhNGVlNzAzNWQ0ZWRhMTM2YmE3OTc2NDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IrGgDJLmDv9kVka5yg7GxmA_NdaeWDIgkhyKY6X9UQQ)
Like here:
![image](https://private-user-images.githubusercontent.com/30603497/278841574-bec7b97d-53de-4a31-b4d8-bbfc44e812e4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDE1NzQtYmVjN2I5N2QtNTNkZS00YTMxLWI0ZDgtYmJmYzQ0ZTgxMmU0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlZDliNDZkZTM3NWJmY2UwYjI4YmZmYTUwNzA3ODJmMjcyYWQwYzk1YWNiYzIxZWMyMTI2NjI3Y2UzM2UxOGEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._0daXhSFZAx-nXBo3ixW7y4vqNgIHtUv7KOY_wXFrXU)
The message comes from this component in the Login.razor
page:
![image](https://private-user-images.githubusercontent.com/30603497/278841586-ac86c4ae-2f00-4ede-8c8c-3fe59a01c38f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDE1ODYtYWM4NmM0YWUtMmYwMC00ZWRlLThjOGMtM2ZlNTlhMDFjMzhmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM2NTI4NjJmZWJjM2MyNGIyY2ZlZTg0ZWNjN2QxNWQyYWY0YjAwOWQ3NGZmZjFhMTJhNmEzYjc2OTBmMDRkNTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.qoP2J489Yd1NEseAaCrm7pFdn0F8nUevfj05jl3WTSg)
![image](https://private-user-images.githubusercontent.com/30603497/278841607-82cda3b4-1fc5-47b2-a308-acce45d1a7d1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDE2MDctODJjZGEzYjQtMWZjNS00N2IyLWEzMDgtYWNjZTQ1ZDFhN2QxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZmYjkyMGNhNDE4NDYxYmRhMGJhYjI0MzcxNzdhOWY2MDNmMzU2YTA4MDhjNTQyNjc4ZjFiZjVjODBjZmQ3ZGYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7TWHGjELFIDqi5bJ0XPjxmmsN8OjK9MEyNlPQ_B00qY)
We're still inside SignInManager.cs
.
Here we Signout external cookie:
![image](https://private-user-images.githubusercontent.com/30603497/278842292-00031e8f-78b7-42ec-8fdf-4e98d21d4563.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDIyOTItMDAwMzFlOGYtNzhiNy00MmVjLThmZGYtNGU5OGQyMWQ0NTYzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5ZDljMWRkMGE5YmUzODM5YTk5NTZmNmQwNWFiNTBjODBhY2E1MTdkZTQ4NmNjOTJjODY2OWRlZmY4Nzk5NzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.sO9VDH5OrIUsSLE_h7e8D7uBFTy7a78vvE-lfPvu4Hc)
And Signin primary cookie:
![image](https://private-user-images.githubusercontent.com/30603497/278842325-4365d496-9cdd-44ea-a2a4-f32d41524a13.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDIzMjUtNDM2NWQ0OTYtOWNkZC00NGVhLWEyYTQtZjMyZDQxNTI0YTEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmZmFiOTc5ZDVkNTNmN2VmZTJiZjFkNzVkMzFkODhjMzhjNjhkNTU2MGQ2OTNmNzBmYmE5OWZlYzc3ODc3NDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wU6zkzfU6YmLSFVRx27Eso1IimPZg93KGC-miHhzbpg)
By calling this method:
![image](https://private-user-images.githubusercontent.com/30603497/278842477-21eba0ce-135c-4d40-963b-9606f31b81b5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI0NzctMjFlYmEwY2UtMTM1Yy00ZDQwLTk2M2ItOTYwNmYzMWI4MWI1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ5NTQ5MTEyMTk5NGJlZjI2MGE5ODE3YzM3MzQ4MGY4Njc1N2E4ZjVhOGYzMDczYjgzZDU0ZTYzOTBmMTFmMzgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.PBx-JxspILSR7dJeb9lx7JydhKrMJmWgL6wKIgsSW5w)
Looks like it adds provider name (github) as an additional claim.
![image](https://private-user-images.githubusercontent.com/30603497/278842532-dbcc552c-2957-4f5f-a6e5-6873c6b6e412.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI1MzItZGJjYzU1MmMtMjk1Ny00ZjVmLWE2ZTUtNjg3M2M2YjZlNDEyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdmYmNhM2FkMjlmZDUwZmMwOTYzNWQyMTZmNjQ2YWY2YmQ4MDhlMjVkY2M3M2Q4Mzc2ZWM0NDU1YWQxNGIyZTImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.kT7_u8OU6Jz2wUAs4QUbnXfmXjR09T95yD-R5L4pgGE)
Then call this method to sign in on primary cookie:
![image](https://private-user-images.githubusercontent.com/30603497/278842613-8dcee766-d097-49f0-aac3-e95039dc14ff.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI2MTMtOGRjZWU3NjYtZDA5Ny00OWYwLWFhYzMtZTk1MDM5ZGMxNGZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0YTY1NmQyMGM3OGUxNWYxZTQwMjA2NmJmYmVkODIxOTRkMWFiNzFiOTUxOGY4MWI0NzM1MzFiOTcwOTBkY2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.MI3l-xG-2n97ZT4o2EjGDF8PUSCaU7WyTqC1_fVoOvk)
Now we're back in ExternalLogin.razor
by logging in the user successfully.
![image](https://private-user-images.githubusercontent.com/30603497/278842647-b73ea334-14d8-4b31-8558-41a7408216e9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI2NDctYjczZWEzMzQtMTRkOC00YjMxLTg1NTgtNDFhNzQwODIxNmU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZjMWFjZTYzZTViYzAyMmFmMjI4NjIzMjMzMjlhZWU2M2JlZTU2NzZlNjA5ZTkyNDFjMWU2NjhkZTE5MTdjNjQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.c1jUmtgm2rRJMdGC1wZIQIk6T3s5ar2yUGT1P2iPt40)
We get to homepage now.
![image](https://private-user-images.githubusercontent.com/30603497/278842837-9bdb9062-226e-4bc0-9d19-a92595277f75.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI4MzctOWJkYjkwNjItMjI2ZS00YmMwLTlkMTktYTkyNTk1Mjc3Zjc1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWJkODdmMjAxZmQxNDE0YjUwZWY2NTVmODU0NTBiZDA5ODNmZmIwZTAzN2ExNWJkMmNmYmQzYmQ5NTQ1ZGZjMGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gAiihgyWXwAy1rtO4sv9qxZG_zkOeC0eC-vTWbkxHGI)
Like this:
![image](https://private-user-images.githubusercontent.com/30603497/278842868-cc1483b7-ac6f-4bf0-bcab-8443825008fa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI4NjgtY2MxNDgzYjctYWM2Zi00YmYwLWJjYWItODQ0MzgyNTAwOGZhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTc0MzM5ZDNhODBkODI3MzYxOWRjMDY2MzQ5MTA1OTZhYmNiZjdhNTYxMjMyMzJkYWQyMmJkYzYwNzA1YTJlMDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.-1OmtxALyfmNCUUVnBdS5I7qizgJgjFdtiBbZUn6DPE)
Now we hit AuthenticationMiddleware
and try to authenticate the user. The Identity.External
cookie is removed and Identity.Application
cookie is present at this point.
![image](https://private-user-images.githubusercontent.com/30603497/278842883-01dd551f-657a-4b98-b62c-47e9c4d4dd91.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI4ODMtMDFkZDU1MWYtNjU3YS00Yjk4LWI2MmMtNDdlOWM0ZDRkZDkxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJjMmQ1N2FhNjBmNTdiNmE4ZDFiYTMzN2M3ZDQxMzJhNTA1MTA5MjkwMjZjMTU3OTQ1OWY2ZGVhYThkY2EzZDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.pGBPaTYavZ80azb1x3Db9cfdkUTitmy1QDNLxVdvYwc)
![image](https://private-user-images.githubusercontent.com/30603497/278842754-8c12158c-99c0-4f0d-a4ae-871f17846713.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI3NTQtOGMxMjE1OGMtOTljMC00ZjBkLWE0YWUtODcxZjE3ODQ2NzEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUzOTA4NDI0ZDA2ZDFlZTk2Y2Q1MDM5ZThjODVlYjA1NzdhNjg5MjFhMTMxZDkzMDExNDQxMjBjNWIxMzA4YjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.RwIEpfv1i63QZ4ytE0onrOuNivOqlZxag9rsi7-CJ3k)
Success!
![image](https://private-user-images.githubusercontent.com/30603497/278842764-661fd65a-2a37-4e3c-9947-9d5b2b07aea7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjYxMDkwNzMsIm5iZiI6MTcyNjEwODc3MywicGF0aCI6Ii8zMDYwMzQ5Ny8yNzg4NDI3NjQtNjYxZmQ2NWEtMmEzNy00ZTNjLTk5NDctOWQ1YjJiMDdhZWE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTEyVDAyMzkzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTliYmI5ZDJiYTJmZTQ1NDZlODEwNTEyNWFiYmRmYzhlOTNmY2ExOGY3YmY2NGZkNjNjNTc1ODYwYzY2Zjg4ZDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7zTcD6N8gDEsGxZagnZ59UUNNwTNbwr_SxmXPNa2utI)