{"id":19741502,"url":"https://github.com/rizamarhaban/identityserver4demo","last_synced_at":"2025-04-30T06:30:43.248Z","repository":{"id":83587350,"uuid":"102174198","full_name":"rizamarhaban/IdentityServer4Demo","owner":"rizamarhaban","description":".NET Developers Community Meetup Demo on August 30, 2017","archived":false,"fork":false,"pushed_at":"2017-10-02T02:28:12.000Z","size":559,"stargazers_count":32,"open_issues_count":1,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-25T11:17:28.077Z","etag":null,"topics":["aspnet-core","aspnetidentity","identityserver"],"latest_commit_sha":null,"homepage":null,"language":"C#","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/rizamarhaban.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-02T05:11:00.000Z","updated_at":"2024-11-22T10:51:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"f247e1db-c165-468d-be06-6931615410bb","html_url":"https://github.com/rizamarhaban/IdentityServer4Demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizamarhaban%2FIdentityServer4Demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizamarhaban%2FIdentityServer4Demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizamarhaban%2FIdentityServer4Demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rizamarhaban%2FIdentityServer4Demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rizamarhaban","download_url":"https://codeload.github.com/rizamarhaban/IdentityServer4Demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251653939,"owners_count":21622224,"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":["aspnet-core","aspnetidentity","identityserver"],"created_at":"2024-11-12T01:26:41.571Z","updated_at":"2025-04-30T06:30:43.239Z","avatar_url":"https://github.com/rizamarhaban.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# IdentityServer4Demo\n[.NET Developers Community Meetup Demo](https://www.meetup.com/NET-Developers-SG/events/242852152/) on August 30, 2017\n\nIn this demo, I use [IdentityServer4 2.0.0-rc1](https://www.nuget.org/packages/IdentityServer4/2.0.0-rc1). You can use the latest preview or if already have the RTM version.\n\nThere are 4 (four) projects in the solution folder, that is:\n\n+ IdentityServer (The ASP.NET Core 2.0 MVC AspNetIdentity using IdentityServer4)\n+ Ids4AspNetIdentity project using .NET Standard 2.0 (taken from [IdentityServer4.AspNetIdentity 2.0.0-rc1](https://github.com/IdentityServer/IdentityServer4.AspNetIdentity))\n+ MyApi (The ASP.NET Core 2.0 Web Api project)\n+ MyWeb (The ASP.NET Core 2.0 MVC project)\n\n## Creating and Installing the Self-Signing Certificate using PowerShell\n\nIf you don't want to create certificate when developing, you can use the ```AddDeveloperSigningCredential()``` example;\n\n``` CSharp\nservices.AddIdentityServer()\n\t.AddDeveloperSigningCredential()\n\t.AddInMemoryIdentityResources(Config.GetIdentityResources())\n\t.AddInMemoryApiResources(Config.GetApis())\n\t.AddInMemoryClients(Config.GetClients())\n\t.AddAspNetIdentity\u003cApplicationUser\u003e();\n```\n\nOtherwise, you can create a self-signing certificate with private key as follow:\n\n``` PowerShell\n$certificate = New-SelfSignedCertificate `\n    -Type Custom `\n    -Provider \"Microsoft Strong Cryptographic Provider\" `\n    -Subject \"CN=rizacert\" `\n    -DnsName localhost `\n    -KeyAlgorithm RSA `\n    -KeyLength 2048 `\n    -KeyExportPolicy ExportableEncrypted `\n    -NotBefore (Get-Date) `\n    -NotAfter (Get-Date).AddYears(6) `\n    -CertStoreLocation \"cert:LocalMachine\\My\" `\n    -FriendlyName \"Localhost Cert IdentityServer\" `\n    -HashAlgorithm SHA256 `\n    -KeyUsage DigitalSignature, KeyEncipherment, DataEncipherment `\n    -TextExtension @(\"2.5.29.37={text}1.3.6.1.5.5.7.3.1\")\n$certificatePath = 'Cert:\\LocalMachine\\My\\' + ($certificate.ThumbPrint)  \n$pwd = ConvertTo-SecureString -String ‘pa$$Word.123’ -Force -AsPlainText\nExport-PfxCertificate -cert $certificatePath -FilePath \"C:\\Demo\\rizacert.pfx\" -Password $pwd\n```\nOnce you have the cert .pfx file, you can install it on the cert store in Windows using the MMC (Microsoft Management Console) with Certificate Snap-in or you can just double-click the file and follow the wizrd to Install. You can choose Local Machine Personal folder to store the certificate.\n\nOn the IdentityServer project Startup.cs, make sure the certificate subject name is the same as what you make on the certificate, on my example case I use \"**CN=rizacert**\":\n\n``` CSharp\nservices.AddIdentityServer()\n  .AddSigningCredential(\"CN=rizacert\")\n  .AddInMemoryIdentityResources(Config.GetIdentityResources())\n  .AddInMemoryApiResources(Config.GetApis())\n  .AddInMemoryClients(Config.GetClients())\n  .AddAspNetIdentity\u003cApplicationUser\u003e();\n```\n\nHow to wire up between the MVC and the API just follow the OpenId connect conecpt. The  grant type for the Web API is cleitn credentials, you can test in Postman like this:\n\n![Postman Example](https://www.rizamarhaban.com/wp-content/uploads/2017/09/Ids4Demo_Client_Credetials.png \"Client Credentials Example\")\n\nIn my case, I use hybrid for the MVC and client credentials for the Web API. You can also change the gran type of the Web API to use resoruce owner if you want to use password as the credentials for login. See the client configuration in the ```Config.cs``` file on the IdentityServer project and just change the **AllowedGrantType** to:\n\n``` CSharp\nAllowedGrantTypes = GrantTypes.ResourceOwnerPassword\n```\n\nTo Test using Postman, you can specify the ```grant_type``` parameter value as ```password```, example:\n\n![Postman Example](https://www.rizamarhaban.com/wp-content/uploads/2017/09/Ids4Demo_ResourceOwnerPassword.png \"Resource Owner Password Example\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizamarhaban%2Fidentityserver4demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frizamarhaban%2Fidentityserver4demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frizamarhaban%2Fidentityserver4demo/lists"}