{"id":13430523,"url":"https://github.com/WildGums/Blorc.OpenIdConnect","last_synced_at":"2025-03-16T05:31:17.313Z","repository":{"id":37019091,"uuid":"239955054","full_name":"WildGums/Blorc.OpenIdConnect","owner":"WildGums","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-28T22:00:39.000Z","size":17457,"stargazers_count":91,"open_issues_count":4,"forks_count":11,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2024-10-29T09:54:52.984Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WildGums.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/support.yml","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"WildGums-oss","ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2020-02-12T07:49:54.000Z","updated_at":"2024-10-28T22:00:41.000Z","dependencies_parsed_at":"2023-12-15T19:19:04.123Z","dependency_job_id":"57f64bc5-564d-47eb-90ba-0eb5a546d523","html_url":"https://github.com/WildGums/Blorc.OpenIdConnect","commit_stats":{"total_commits":739,"total_committers":8,"mean_commits":92.375,"dds":0.6305818673883626,"last_synced_commit":"c82d4ef08b8b9d83d936af2043cf17adef4cb703"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WildGums%2FBlorc.OpenIdConnect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WildGums%2FBlorc.OpenIdConnect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WildGums%2FBlorc.OpenIdConnect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WildGums%2FBlorc.OpenIdConnect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WildGums","download_url":"https://codeload.github.com/WildGums/Blorc.OpenIdConnect/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243558470,"owners_count":20310573,"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-07-31T02:00:54.874Z","updated_at":"2025-03-16T05:31:15.682Z","avatar_url":"https://github.com/WildGums.png","language":"C#","funding_links":["https://opencollective.com/WildGums-oss"],"categories":["Sample Projects"],"sub_categories":["Authentication"],"readme":"# Blorc.OpenIdConnect\n\nThe right way to use OpenIdConnect on Blazor.\n\n## Usage\n\n1) Install Blorc.OpenIdConnect via NuGet.\n\n2) Include `Blorc.Core/injector.js` the index.html file:\n\n```html\n\u003chead\u003e\n    \u003c!-- ... --\u003e\n    \u003cscript src=\"_content/Blorc.Core/injector.js\"\u003e\u003c/script\u003e\n    \u003c!-- ... --\u003e\n\u003c/head\u003e\n```\n \n3) Update App.razor content like this:\n\n```razor\n@using Microsoft.AspNetCore.Components.Authorization\n\n\u003cCascadingAuthenticationState\u003e\n    \u003cRouter AppAssembly=\"@typeof(Program).Assembly\"\u003e\n        \u003cFound Context=\"routeData\"\u003e\n            \u003cAuthorizeRouteView RouteData=\"@routeData\" DefaultLayout=\"@typeof(MainLayout)\" /\u003e\n        \u003c/Found\u003e\n        \u003cNotFound\u003e\n            \u003cLayoutView Layout=\"@typeof(MainLayout)\"\u003e\n            \u003cp\u003eSorry, there's nothing at this address.\u003c/p\u003e\n            \u003c/LayoutView\u003e\n        \u003c/NotFound\u003e\n    \u003c/Router\u003e\n\u003c/CascadingAuthenticationState\u003e\n```\n        \n4) Add the required service and update Program.cs file as follow:\n\n```csharp\n// Add access token delegating handler to registered http clients\nvar baseUrl = builder.HostEnvironment.BaseAddress;\nbuilder.Services\n    .AddHttpClient\u003cWeatherForecastHttpClient\u003e(client =\u003e client.BaseAddress = new Uri(baseUrl))\n    .AddAccessToken();\n\n// Registering required services\nbuilder.Services.AddBlorcCore();\nbuilder.Services.AddAuthorizationCore();\nbuilder.Services.AddBlorcOpenIdConnect(\n    options =\u003e\n    {\n        builder.Configuration.Bind(\"IdentityServer\", options);\n    });\n\nvar webAssemblyHost = builder.Build();\n\nawait webAssemblyHost\n    .ConfigureDocumentAsync(\n        async documentService =\u003e\n        {\n            await documentService.InjectBlorcCoreJsAsync();\n            await documentService.InjectOpenIdConnectAsync();\n        });\n\nawait webAssemblyHost.RunAsync();\n```\n\n5) Configure the client and identity server as described in the [Configuration](#configuration) section.\n\n## Configuration\n\n### Client\n\nAdd a configuration file `wwwroot\\appsettings.json`\n\n\u003e [!NOTE]\n\u003e The Authorization Code Flow with Proof Key for Code Exchange (PKCE) is an authorization code flow to prevent CSRF and authorization code injection attacks and it is the only supported method. Use the configuration values as shown below.\n\n```jsonc\n{\n  \"IdentityServer\": {\n    \"ResponseType\": \"code\",\n    \"Scope\": \"openid profile %API-NAME%\",\n    \"RedirectUri\": \"%APPLICATION_URL%\",\n    \"PostLogoutRedirectUri\": \"%APPLICATION_URL%\",\n    \"Authority\": \"%IDENTITY_SERVER_URL%\",\n    \"ClientId\": \"%CLIENT_ID%\",\n    \"AutomaticSilentRenew\": true, // or `false`\n    \"FilterProtocolClaims\": true,\n    \"LoadUserInfo\": true\n  }\n}\n```\n\nYou can also configure the client when registering the service:\n\n```csharp\nbuilder.Services.AddBlorcOpenIdConnect(\n    options =\u003e\n    {\n        options.ResponseType = \"code\";\n        // ...\n    });\n```\n\n\u003e Configuration sample code can be found in the [demo app](src/Blorc.OpenIdConnect.DemoApp/Program.cs).\n\nSome of the configuration options are described in the following table:\n\n| Option | Description |\n|--------|-------------|\n| LoadUserInfo | Flag to control if additional identity data is loaded from the user info endpoint in order to populate the user's profile. |\n| Resource | The `resource` parameter to send to the identity server. Useful when the identity server supports [RFC 8707](https://datatracker.ietf.org/doc/html/rfc8707). |\n| ExtraQueryParams | Additional query string parameters to be including in the authorization request. |\n| ExtraTokenParams | Additional parameters to be sent to the token endpoint. |\n\n### Identity server\n\nUse the following guides as reference for identity server configuration.  \n\n- [Authorization Code flow with PKCE (Keycloak)](https://www.appsdeveloperblog.com/pkce-verification-in-authorization-code-grant/)\n- [PKCE Verification in Authorization Code Grant (Auth0)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-proof-key-for-code-exchange-pkce)\n\n\n## Run demo app\n\n1) Prerequisites\n\n   - Docker\n   - [Tye](https://github.com/dotnet/tye)\n\n2) Open a command line console a run the following commands\n\n```bash\n\u003e cd %CLONE_DIR%\\deployment\\tye\n\u003e tye run .\\backend-tye.yaml\n```\n\n3) Run the InitializeKeycloakAsync test of the Environment class in the test project. This will setup the required clients, and client scope for the demo.\n\n4) Run the `Blorc.OpenIdConnect.DemoApp.Server` project.\n\n5) Use the following credentials when prompted by Keycloak.\n\n| UserName | Password     |\n|----------|--------------|\n| admin    | Password123! |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWildGums%2FBlorc.OpenIdConnect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWildGums%2FBlorc.OpenIdConnect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWildGums%2FBlorc.OpenIdConnect/lists"}