{"id":22700142,"url":"https://github.com/sravimohan/blazor-webassembly-cognito-hosted-ui-sample","last_synced_at":"2025-04-13T05:52:49.586Z","repository":{"id":198413831,"uuid":"492605205","full_name":"sravimohan/blazor-webassembly-cognito-hosted-ui-sample","owner":"sravimohan","description":"Sample Blazor Web assembly project Using Cognito Hosted UI Authentication","archived":false,"fork":false,"pushed_at":"2022-05-15T22:11:45.000Z","size":195,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T05:52:44.762Z","etag":null,"topics":["asp-net","asp-net-core","aws","aws-cognito","blazor-webassembly","dotnet"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sravimohan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-05-15T21:12:46.000Z","updated_at":"2024-10-25T04:45:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"540fb5a8-b22b-46cf-a35d-6146f0b38a06","html_url":"https://github.com/sravimohan/blazor-webassembly-cognito-hosted-ui-sample","commit_stats":null,"previous_names":["sravimohan/blazor-webassembly-cognito-hosted-ui-sample"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sravimohan","download_url":"https://codeload.github.com/sravimohan/blazor-webassembly-cognito-hosted-ui-sample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670503,"owners_count":21142901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asp-net","asp-net-core","aws","aws-cognito","blazor-webassembly","dotnet"],"created_at":"2024-12-10T06:10:10.737Z","updated_at":"2025-04-13T05:52:49.559Z","avatar_url":"https://github.com/sravimohan.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sample Blazor Webassembly project Using Cognito Hosted UI Authentication\n\n- Create dotnet WASM project\n\n    ```dotnet new blazorwasm -au Individual -o BlazorWasmCognitoSample```\n\n    This should create a Blazor WASM project with Indivdual type authentication\n\n- [Optional] Create AWS Cognito User Pool. \n\n    [Sample Cloudformation - cognito-stack.yml](./.cloudformation/cognito-stack.yml)\n\n    [Deploy Script - deploy-cognito-stack.sh](./.cloudformation/deploy-cognito-stack.sh)\n\n    If you are using an existing user pool, make sure the CallbackURLs and LogoutURLs match exactly.  A common cause of grief is the missing or additional trailing slashes.\n\n    Also you will need to configure the Hosted UI.\n\n- Update appsettings.json or appsettings.development.json under wwwroot.  Make sure to replace \u003cAWS_REGION\u003e, \u003cAWS_COGNITO_USERPOOL_ID\u003e, \u003cAWS_COGNITO_APP_CLIENT_ID\u003e with your values.\n    ```\n    {\n        \"Cognito\": {\n            \"Authority\": \"https://cognito-idp.\u003cAWS_REGION\u003e.amazonaws.com/\u003cAWS_COGNITO_USERPOOL_ID\u003e\",\n            \"ClientId\": \"\u003cAWS_COGNITO_APP_CLIENT_ID\u003e\",\n            \"RedirectUri\": \"https://localhost:5001/authentication/login-callback\",\n            \"PostLogoutRedirectUri\": \"https://localhost:5001/authentication/logout-callback\",\n            \"ResponseType\": \"code\"\n        }\n    }\n    ```\n- Update Program.cs, to refer to the correct config\n    ```\n    builder.Services.AddOidcAuthentication(options =\u003e\n    {\n        builder.Configuration.Bind(\"Cognito\", options.ProviderOptions);\n    });\n    ```    \n    \n- Add Authorize Attribute to pages which needs to be protected\n    ```\n        @using Microsoft.AspNetCore.Authorization\n\n        @page \"/fetchdata\"\n        @attribute [Authorize]\n        @inject HttpClient Http\n\n        \u003cPageTitle\u003eWeather forecast\u003c/PageTitle\u003e\n\n        ...\n    ```\n\n- Run\n    ```dotnet run```\n\nPlease refer to https://docs.microsoft.com/en-au/aspnet/core/blazor/security/webassembly/?view=aspnetcore-6.0 for official documentation.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsravimohan%2Fblazor-webassembly-cognito-hosted-ui-sample/lists"}