{"id":23108090,"url":"https://github.com/bytexdigital/bytexdigital.blazor.server.authentication","last_synced_at":"2025-05-06T00:50:56.713Z","repository":{"id":103210933,"uuid":"272681074","full_name":"BytexDigital/BytexDigital.Blazor.Server.Authentication","owner":"BytexDigital","description":"Authentication library for serversided Blazor","archived":false,"fork":false,"pushed_at":"2020-09-16T08:36:47.000Z","size":48,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T01:11:09.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BytexDigital.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-16T10:43:01.000Z","updated_at":"2024-08-14T21:48:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"fb95fce0-8087-4a9e-85cf-85e5b38be090","html_url":"https://github.com/BytexDigital/BytexDigital.Blazor.Server.Authentication","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytexDigital%2FBytexDigital.Blazor.Server.Authentication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytexDigital%2FBytexDigital.Blazor.Server.Authentication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytexDigital%2FBytexDigital.Blazor.Server.Authentication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BytexDigital%2FBytexDigital.Blazor.Server.Authentication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BytexDigital","download_url":"https://codeload.github.com/BytexDigital/BytexDigital.Blazor.Server.Authentication/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252601674,"owners_count":21774657,"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":[],"created_at":"2024-12-17T01:17:22.508Z","updated_at":"2025-05-06T00:50:56.613Z","avatar_url":"https://github.com/BytexDigital.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BytexDigital.Blazor.Server.Authentication\n\nThis library adds a simple way of being able to sign in, sign out and remember the signed in user (e.g. via cookies) directly from Blazor without the need of redirecting the user to Razor pages.\n\nExisting Blazor components such as `AuthorizeView` will continue to work as expected.\n\n\u003e :warning: **This library is meant only for server-sided Blazor.**\n\n## Download\n[:arrow_forward: **BytexDigital.Blazor.Server.Authentication** Nuget package](https://www.nuget.org/packages/BytexDigital.Blazor.Server.Authentication/)\n![nuget BytexDigital.Blazor.Server.Authentication](https://img.shields.io/nuget/vpre/BytexDigital.Blazor.Server.Authentication.svg?style=flat-square)\n\n[:arrow_forward: **BytexDigital Blazor.Server.Authentication.Identity** Nuget package](https://www.nuget.org/packages/BytexDigital.Blazor.Server.Authentication.Identity/)\n![nuget BytexDigital.Blazor.Server.Authentication.Identity](https://img.shields.io/nuget/vpre/BytexDigital.Blazor.Server.Authentication.Identity.svg?style=flat-square)\n\n## How to use?\n#### 1. Install `BytexDigital.Blazor.Server.Authentication` or `BytexDigital.Blazor.Server.Authentication.Identity`\n#### 2. Register the necessary services\nMake sure to register the services **after other calls to add Authentication services**.\n\n##### Required in all cases\n```csharp\nservices.AddHttpContextAccessor();\n```\n\n##### With Identity\n```csharp\nservices\n    .AddAuthenticationService()\n    .AddCookiePrincipalStorage()\n    .AddIdentityPrincipalProvider\u003cApplicationUser\u003e();\n```\n\n##### Without Identity\n```csharp\nservices\n    .AddAuthenticationService()\n    .AddCookiePrincipalStorage()\n    .AddPrincipalProvider\u003cImplementationOfIPrincipalProvider\u003e();\n```\n\n#### 3. Add the Javascript to your `_Host.cshtml`\n```html\n\u003cscript src=\"/_content/BytexDigital.Blazor.Server.Authentication/bundle.js\"\u003e\u003c/script\u003e\n```\n\n#### Edit your `App.razor` to wrap your content in a `CascadingAuthenticationProvider`\n\n```cshtml\n\u003cBytexDigital.Blazor.Server.Authentication.CascadingAuthenticationProvider\u003e\n\t\u003cRouter AppAssembly=\"@typeof(Program).Assembly\"\u003e\n\t\t\u003cFound Context=\"routeData\"\u003e\n\t\t\t\u003cRouteView RouteData=\"@routeData\" DefaultLayout=\"@typeof(MainLayout)\" /\u003e\n\t\t\u003c/Found\u003e\n\t\t\u003cNotFound\u003e\n\t\t\t\u003cLayoutView Layout=\"@typeof(MainLayout)\"\u003e\n\t\t\t\t\u003cNotFound\u003e\u003c/NotFound\u003e\n\t\t\t\u003c/LayoutView\u003e\n\t\t\u003c/NotFound\u003e\n\t\u003c/Router\u003e\n\u003c/BytexDigital.Blazor.Server.Authentication.CascadingAuthenticationProvider\u003e\n```\n\n\n## Sign in and sign out\nUse `IServerAuthenticationService.SignInAsAsync` and `IServerAuthenticationService.SignOutAsync` to change the signed in user.\nReloading the page is not necessary. You can use `IServerAuthenticationService.GetSignedInIdOrDefault` and `IServerAuthenticationService.IsSignedIn` to get information about the current authentication status.\n\n## Questions\n### What is the `IPrincipalProvider`?\nThe `IPrincipalProvider` is used to convert a user id to a `ClaimsPrincipal` object. The included `IdentityPrincipalProvider` will convert the user id to a principal using a `UserStore\u003cTUser\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytexdigital%2Fbytexdigital.blazor.server.authentication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbytexdigital%2Fbytexdigital.blazor.server.authentication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbytexdigital%2Fbytexdigital.blazor.server.authentication/lists"}