﻿
{"id":18730,"date":"2020-11-01T11:54:31","date_gmt":"2020-11-01T11:54:31","guid":{"rendered":"https:\/\/www.gencayyildiz.com\/blog\/?p=18730"},"modified":"2020-11-02T23:10:19","modified_gmt":"2020-11-02T23:10:19","slug":"identityserver4-yazi-serisi-11-merkezi-uyelik-sistemi-temelleri","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/identityserver4-yazi-serisi-11-merkezi-uyelik-sistemi-temelleri\/","title":{"rendered":"IdentityServer4 Yaz\u0131 Serisi #11 &#8211; Merkezi \u00dcyelik Sistemi Temelleri"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Merhaba,<\/p>\n<p>Bu i\u00e7eri\u011fimizde <a href=\"https:\/\/www.gencayyildiz.com\/blog\/identityserver4-yazi-serisi\/\" rel=\"noopener noreferrer\" target=\"_blank\">yaz\u0131 serimiz<\/a> boyunca ara ara geli\u015ftirdi\u011fimiz \u00f6rnek uygulama \u00fczerinden Merkezi \u00dcyelik Sistemi&#8217;ni \u00f6rneklendirece\u011fiz. Geli\u015ftirdi\u011fimiz uygulaman\u0131n bu makaleye kadar olan en son halini elde edebilmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4Example-2.zip\">buraya<\/a> t\u0131klay\u0131n\u0131z.<\/p>\n<p>\u015eimdi <em>Merkezi \u00dcyelik Sistemi<\/em> \u00f6rneklendirmesi i\u00e7in ad\u0131m ad\u0131m a\u015fa\u011f\u0131daki \u00f6nergeleri takip edelim;<\/p>\n<ul>\n<li><strong>Ad\u0131m 1<\/strong><br \/>\n\u0130lk olarak Auth Server&#8217;da bir login sayfas\u0131na ihtiyac\u0131m\u0131z vard\u0131r. Lakin bu sayfay\u0131 bizler manuel tasarlamaktansa IdentityServer4 geli\u015ftiricilerinin cenneti garanti etmek pahas\u0131na bizlere sunmu\u015f oldu\u011fu <a href=\"https:\/\/github.com\/IdentityServer\/IdentityServer4.Quickstart.UI\" rel=\"noopener noreferrer\" target=\"_blank\" class=\"broken_link\">IdentityServer4.Quickstart.UI<\/a> paketini kullanabiliriz. <\/p>\n<p>\u0130lgili paketi kurabilmek i\u00e7in verilen adrese t\u0131klad\u0131\u011f\u0131n\u0131zda a\u00e7\u0131lan sayfada bulunan &#8216;Adding the quickstart UI&#8217; ba\u015fl\u0131\u011f\u0131 alt\u0131ndaki powershell kodunu kopyalay\u0131p &#8216;AuthServer&#8217; uygulamas\u0131n\u0131n dizininde Powershell \u00fczerinden \u00e7al\u0131\u015ft\u0131r\u0131n\u0131z.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-1.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"841\" height=\"204\" class=\"alignleft size-full wp-image-18626\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-1.png 841w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-1-300x73.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-1-768x186.png 768w\" sizes=\"auto, (max-width: 841px) 100vw, 841px\" \/><\/a><br \/>\n<div id=\"attachment_18629\" style=\"width: 1104px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-18629\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"1094\" height=\"100\" class=\"size-full wp-image-18629\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2.png 1094w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2-300x27.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2-1024x94.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-2-768x70.png 768w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/a><p id=\"caption-attachment-18629\" class=\"wp-caption-text\">Kod \u00e7al\u0131\u015ft\u0131r\u0131ld\u0131\u011f\u0131nda uzaktan y\u00fckleme ve geni\u015fletme s\u00fcreci&#8230;<\/p><\/div><br \/>\n<div id=\"attachment_18630\" style=\"width: 1357px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-18630\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"1347\" height=\"219\" class=\"size-full wp-image-18630\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3.png 1347w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3-300x49.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3-1024x166.png 1024w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-3-768x125.png 768w\" sizes=\"auto, (max-width: 1347px) 100vw, 1347px\" \/><\/a><p id=\"caption-attachment-18630\" class=\"wp-caption-text\">Y\u00fckleme tamamland\u0131ktan sonra nihai olarak dosyalar\u0131n olu\u015fturulmas\u0131&#8230;<\/p><\/div><br \/>\nPaketi y\u00fckledikten sonra olu\u015fturulan dosyalara \u015f\u00f6yle bir g\u00f6z atarsak e\u011fer;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-4.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"314\" height=\"510\" class=\"alignleft size-full wp-image-18632\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-4.png 314w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-4-185x300.png 185w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><\/a><br \/>\nG\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere kullan\u0131c\u0131 i\u015flemlerine dair akl\u0131n\u0131za gelebilecek t\u00fcm \u00e7al\u0131\u015fmalar controller olarak tasarlanm\u0131\u015f bulunmaktad\u0131r. &#8216;IdentityServer4.Quickstart.UI&#8217; paketi IdentityServer4 ile ilgili t\u00fcm i\u015flemleri tek sat\u0131r kod yazmaya gerek kalmaks\u0131z\u0131n b\u00fcnyesinde bar\u0131nd\u0131rmaktad\u0131r. Bizlere tek d\u00fc\u015fen paketin sunmu\u015f oldu\u011fu .cshtml dosyalar\u0131 i\u00e7erisindeki tasar\u0131mlarla oynamak, css vs. gibi dosyalarda d\u00fczeltmeler yapmakt\u0131r. Makale serimizin devam\u0131nda bu paketin daha da derinlemesine kullan\u0131m\u0131n\u0131 inceleyece\u011fimizden dolay\u0131 \u015fimdilik pek \u00fczerinde durmaks\u0131z\u0131n yola devam ediyoruz&#8230; <br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;\n<\/li>\n<li><strong>Ad\u0131m 2<\/strong><br \/>\n&#8216;AuthServer&#8217; projesinde kullan\u0131lan &#8216;IdentityServer4.Quickstart.UI&#8217; paketinden dolay\u0131 MVC tabanl\u0131 bir \u00e7al\u0131\u015fma yap\u0131lacakt\u0131r. Haliyle &#8216;Startup.cs&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki servislerin eklenmesi ve middleware&#8217;lerin \u00e7a\u011fr\u0131lmas\u0131 gerekmektedir;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            .\r\n            .\r\n            .\r\n            services.AddControllersWithViews(); \/\/MVC i\u00e7in\r\n        }\r\n\r\n        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)\r\n        {\r\n            .\r\n            .\r\n            .\r\n            app.UseRouting();\r\n            app.UseStaticFiles(); \/\/wwwroot'a eri\u015fim i\u00e7in\r\n            app.UseAuthentication(); \/\/kimlik do\u011frulama i\u00e7in\r\n            app.UseAuthorization(); \/\/yetkilendirme i\u00e7in\r\n\r\n            app.UseIdentityServer();\r\n\r\n            app.UseEndpoints(endpoints =&gt;\r\n            {\r\n                endpoints.MapDefaultControllerRoute(); \/\/url rotas\u0131 i\u00e7in\r\n            });\r\n            .\r\n            .\r\n            .\r\n        }\r\n    }\r\n<\/pre>\n<\/li>\n<li><strong>Ad\u0131m 3<\/strong><br \/>\nBu konfig\u00fcrasyonlardan sonra &#8216;AuthServer&#8217; uygulamas\u0131n\u0131 aya\u011fa kald\u0131ral\u0131m ve test edelim.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-5-300x250.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"300\" height=\"250\" class=\"alignleft size-medium wp-image-18643\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-5-300x250.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-5.png 538w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere &#8216;AuthServer&#8217; uygulamas\u0131 direkt olarak bir UI ile bizi kar\u015f\u0131lamaktad\u0131r. Burada oturumumuzla ilgili bilgileri g\u00f6rebilmek i\u00e7in &#8216;Click here to see the claims for your current session.&#8217; yaz\u0131s\u0131ndaki &#8216;here&#8217; linkine t\u0131klayal\u0131m.<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<\/p>\n<p><a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-6-185x300.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"185\" height=\"300\" class=\"alignright size-medium wp-image-18648\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-6-185x300.png 185w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-6.png 319w\" sizes=\"auto, (max-width: 185px) 100vw, 185px\" \/><\/a>G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere ilgili linke t\u0131klad\u0131\u011f\u0131m\u0131zda herhangi bir oturum a\u00e7\u0131k olmad\u0131\u011f\u0131 i\u00e7in bizi login sayfas\u0131na y\u00f6nlendirmektedir. Tabi ki de login olabilmek i\u00e7in \u00f6ncelikle bir kullan\u0131c\u0131 tan\u0131mlamam\u0131z gerekmektedir. Bunu \u015fimdilik bu makalede ger\u00e7ekle\u015ftirmeyecek ve In-Memory&#8217;de test user&#8217;lar tutaca\u011f\u0131z. Nihayetinde bu makalede amac\u0131m\u0131z kullan\u0131c\u0131 kayd\u0131 de\u011fildir. <br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;\n<\/li>\n<li><strong>Ad\u0131m 4<\/strong><br \/>\n&#8216;AuthServer&#8217;da yetki verebilmek i\u00e7in kullan\u0131c\u0131lara ihtiyac\u0131m\u0131z vard\u0131r. Konumuz gere\u011fi kullan\u0131c\u0131 kay\u0131t i\u015flemleriyle u\u011fra\u015fmamak ve development a\u015famas\u0131nda h\u0131zl\u0131ca kullan\u0131c\u0131 aya\u011fa kald\u0131rabilmek i\u00e7in In-Memory&#8217;de test user&#8217;lar tan\u0131mlayaca\u011f\u0131z. Bunun i\u00e7in &#8216;AuthServer&#8217; uygulamas\u0131nda ki &#8216;Config.cs&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki metodu tasarlamam\u0131z gerekmektedir.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public static IEnumerable&lt;TestUser&gt; GetTestUsers()\r\n        {\r\n            return new List&lt;TestUser&gt; {\r\n                new TestUser {\r\n                    SubjectId = &quot;test-user1&quot;,\r\n                    Username = &quot;test-user1&quot;,\r\n                    Password = &quot;12345&quot;,\r\n                    Claims = {\r\n                        new Claim(&quot;name&quot;,&quot;test user1&quot;),\r\n                        new Claim(&quot;website&quot;,&quot;https:\/\/wwww.testuser1.com&quot;),\r\n                        new Claim(&quot;gender&quot;,&quot;1&quot;)\r\n                    }\r\n                },\r\n                new TestUser {\r\n                    SubjectId = &quot;test-user2&quot;,\r\n                    Username = &quot;test-user2&quot;,\r\n                    Password = &quot;12345&quot;,\r\n                    Claims = {\r\n                        new Claim(&quot;name&quot;,&quot;test user2&quot;),\r\n                        new Claim(&quot;website&quot;,&quot;https:\/\/wwww.testuser2.com&quot;),\r\n                        new Claim(&quot;gender&quot;,&quot;0&quot;)\r\n                    }\r\n                }\r\n            };\r\n        }\r\n<\/pre>\n<p>Yukar\u0131daki kodu incelerseniz e\u011fer test user&#8217;lar\u0131 &#8216;IdentityServer4.Test&#8217; namespace&#8217;i alt\u0131ndaki &#8216;TestUser&#8217; nesnesi ile tan\u0131mlamaktay\u0131z. Tan\u0131mlanan test user&#8217;lar\u0131n claim&#8217;lerine g\u00f6z atarsan\u0131z e\u011fer &#8216;name&#8217;, &#8216;website&#8217;, &#8216;gender&#8217; gibi bilgiler tutulmaktad\u0131r. Bu bilgiler IdentityServer4 mekanizmas\u0131nda bir user profili i\u00e7in \u00f6nceden tan\u0131mlanm\u0131\u015f default anahtarlar e\u015fli\u011finde yaz\u0131lmaktad\u0131r.<\/p>\n<p>Bir user profili i\u00e7in varsay\u0131lan olarak ayarlanm\u0131\u015f t\u00fcm claim anahtarlar\u0131 \u015funlard\u0131r; <code>name<\/code>, <code>family_name<\/code>, <code>given_name<\/code>, <code>middle_name<\/code>, <code>nickname<\/code>, <code>preferred_username<\/code>, <code>profile<\/code>, <code>picture<\/code>, <code>website<\/code>, <code>gender<\/code>, <code>birthdate<\/code>, <code>zoneinfo<\/code>, <code>locale<\/code>, <code>updated_at<\/code>\n<\/li>\n<li><strong>Ad\u0131m 5<\/strong><br \/>\nTest user&#8217;lar\u0131 tan\u0131mlad\u0131ktan sonra s\u0131rada &#8216;IdentityResource&#8217; tan\u0131mlamaya gelmi\u015ftir. &#8216;IdentityResource&#8217;\u00fc a\u00e7\u0131klamam\u0131z gerekirse e\u011fer;<br \/>\nClient&#8217;lar giri\u015f yapan kullan\u0131c\u0131lar\u0131n farkl\u0131 bilgilerini isteyebilmektedirler. Bu bilgileri alabilmeleri i\u00e7in &#8216;IdentityResource&#8217; tan\u0131mlanmal\u0131d\u0131r. Bu &#8216;IdentityResource&#8217;ler client&#8217;lara verilerek hangi bilgileri alabilecekleri bildirilebilmektedir. \u00d6rne\u011fin; &#8216;client1&#8217;e email ile ilgili identity resource verilirse client taraf\u0131ndan ilgili kullan\u0131c\u0131n\u0131n sadece email bilgisi al\u0131nm\u0131\u015f olacakt\u0131r. Benzer mant\u0131kla &#8216;client2&#8217;ye email ve username ile ilgili identity resource verilirse bu seferde ad\u0131 ge\u00e7en kullan\u0131c\u0131n\u0131n ilgili bilgileri al\u0131nm\u0131\u015f olacakt\u0131r.<\/p>\n<p>&#8216;IdentityResource&#8217; tan\u0131mlayabilmek i\u00e7in tekrar &#8216;Config.cs&#8217;e gelerek a\u015fa\u011f\u0131daki metot olu\u015fturulmal\u0131d\u0131r;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public static IEnumerable&lt;IdentityResource&gt; GetIdentityResources()\r\n        {\r\n            return new List&lt;IdentityResource&gt;\r\n            {\r\n                new IdentityResources.OpenId(),\r\n                new IdentityResources.Profile()\r\n            };\r\n        }\r\n<\/pre>\n<p>Burada tan\u0131mlanan &#8216;IdentityResource&#8217;leri incelersek e\u011fer;<\/p>\n<ul>\n<li><em style=\"color:red;\">OpenId :<\/em> \u00dcretilecek token i\u00e7erisinde kesinlikle bir kullan\u0131c\u0131 id\/user id\/subject id olmal\u0131d\u0131r. OpenId kullan\u0131c\u0131 id de\u011ferini ifade eder. Token&#8217;da &#8216;subid&#8217; olarak tutulacakt\u0131r.<\/li>\n<li><em style=\"color:red;\">Profile :<\/em> Kullan\u0131c\u0131 profil bilgilerini ve biryandan da kullan\u0131c\u0131 i\u00e7in var olan t\u00fcm claim&#8217;leri bar\u0131nd\u0131r\u0131r.<\/li>\n<\/ul>\n<p>Bu iki de\u011ferde kendi b\u00fcnyelerinde bir\u00e7ok claim bar\u0131nd\u0131rabilmektedirler. Hatta &#8216;Profile&#8217; ile ilgili bir\u00e7ok claim&#8217;i bir \u00f6nceki ad\u0131mda not alm\u0131\u015ft\u0131k.\n<\/li>\n<li><strong>Ad\u0131m 6<\/strong><br \/>\n&#8216;Config.cs&#8217; dosyas\u0131nda tan\u0131mlanan user&#8217;lar ile birlikte &#8216;IdentityResource&#8217;leri  &#8216;AuthServer&#8217; uygulamas\u0131na eklememiz gerekmektedir. Bunun i\u00e7in &#8216;Startup.cs&#8217;de &#8216;AddIdentityServer&#8217; metodu \u00fczerinden &#8216;AddTestUsers&#8217; ve &#8216;AddInMemoryIdentityResources&#8217; metotlar\u0131 ile a\u015fa\u011f\u0131daki gibi ekleme i\u015flemini ger\u00e7ekle\u015ftirebiliriz; <\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            .\r\n            .\r\n            .\r\n            services.AddIdentityServer()\r\n                .AddInMemoryApiResources(Config.GetApiResources())\r\n                .AddInMemoryApiScopes(Config.GetApiScopes())\r\n                .AddInMemoryClients(Config.GetClients())\r\n                .AddTestUsers(Config.GetTestUsers().ToList())\r\n                .AddInMemoryIdentityResources(Config.GetIdentityResources())\r\n                .AddDeveloperSigningCredential();\r\n            .\r\n            .\r\n            .\r\n        }\r\n<\/pre>\n<\/li>\n<li><strong>Ad\u0131m 7<\/strong><br \/>\n\u015eimdi bu i\u015flemlerden sonra tekrar &#8216;AuthServer&#8217; uygulamas\u0131n\u0131 aya\u011fa kald\u0131ral\u0131m ve test edelim.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-7-177x300.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"177\" height=\"300\" class=\"alignleft size-medium wp-image-18660\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-7-177x300.png 177w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-7.png 267w\" sizes=\"auto, (max-width: 177px) 100vw, 177px\" \/><\/a><br \/>\nBiraz \u00f6nce tan\u0131mlad\u0131\u011f\u0131m\u0131z kullan\u0131c\u0131 ad\u0131 ve \u015fifreyi girerek &#8216;Login&#8217; butonuna t\u0131klayal\u0131m.<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>&nbsp;<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-8-300x202.png\" alt=\"\" width=\"300\" height=\"202\" class=\"alignright size-medium wp-image-18667\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-8-300x202.png 300w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-8-768x517.png 768w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-8.png 928w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\nEvet&#8230; G\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere kullan\u0131c\u0131(test) olarak &#8216;AuthServer&#8217;da bir login i\u015flemi ger\u00e7ekle\u015ftirmi\u015f olduk. Haliyle kullan\u0131c\u0131 bilgileri ekranda listelenmektedir. Hatta taray\u0131c\u0131n\u0131n Cookie de\u011ferlerine bakarsan\u0131z &#8216;AuthServer&#8217; taraf\u0131ndan &#8216;idsrv&#8217; anahtar\u0131 kar\u015f\u0131l\u0131\u011f\u0131na bir de\u011fer yerle\u015ftirildi\u011fini dahi g\u00f6receksiniz.<\/p>\n<p>Lakin burada dikkat edilmesi gereken bir husus s\u00f6z konusudur. O da yukar\u0131daki g\u00f6rsele tekrar bakarsan\u0131z &#8216;Claims&#8217; k\u0131sm\u0131nda yazan &#8216;amr&#8217; ba\u015fl\u0131\u011f\u0131yla alakal\u0131d\u0131r. Bu ba\u015fl\u0131k ilgili authentication i\u015fleminin tipini yani grant tipini bizlere sunmaktad\u0131r. &#8216;pwd&#8217; esas\u0131nda password demektir ve bu, ileride pratiksel olarak g\u00f6rece\u011fimiz grant tiplerinden biri olan &#8216;<em><a href=\"https:\/\/www.gencayyildiz.com\/blog\/identityserver4-yazi-serisi-10-resource-owner-credentials-grantflow\/\" rel=\"noopener noreferrer\" target=\"_blank\">Resource Owner Credentials Grant<\/a><\/em>&#8216;\u0131 temsil etmektedir. Art\u0131k yetkilendirme i\u00e7in bir client uygulamas\u0131na ihtiyac\u0131m\u0131z olacak.\n<\/li>\n<li><strong>Ad\u0131m 8<\/strong><br \/>\nBu a\u015famadan sonra client tasar\u0131m\u0131na ge\u00e7memiz gerekmektedir. Burada tasarlamaktan kast\u0131m\u0131z tabi ki de g\u00f6rsel bir \u00e7al\u0131\u015fma de\u011fildir. Mimarisel tasar\u0131m kastedilmektedir \ud83d\ude42 Client&#8217;\u0131 tasarlad\u0131ktan sonra kullan\u0131c\u0131y\u0131 &#8216;AuthServer&#8217;a authentication code onay\u0131 i\u00e7in y\u00f6nlendirece\u011fiz. Burada gerekli UI&#8217;\u0131 yine &#8216;IdentityServer4.Quickstart.UI&#8217; k\u00fct\u00fcphanesi sa\u011flayacakt\u0131r.<\/p>\n<p>Tasarlayaca\u011f\u0131m\u0131z client \u015fimdilik bir web uygulamas\u0131(Asp.NET Core MVC) olacakt\u0131r. \u015eimdi ilgili projeyi olu\u015ftural\u0131m<span style=\"font-size:11px;\">(Projeye OnlineBankamatik ad\u0131n\u0131 veriyorum)<\/span> ve temel konfig\u00fcrasyonlar\u0131n\u0131 yapal\u0131m. Ard\u0131ndan ilgili client&#8217;ta kimlik do\u011frulama ve cookie i\u015flemleri i\u00e7in <a href=\"https:\/\/www.nuget.org\/packages\/Microsoft.AspNetCore.Authentication.OpenIdConnect\" rel=\"noopener noreferrer\" target=\"_blank\">Microsoft.AspNetCore.Authentication.OpenIdConnect<\/a> k\u00fct\u00fcphanesini y\u00fcklememiz gerekmektedir. <em><strong>Neden bu k\u00fct\u00fcphaneyi y\u00fckl\u00fcyoruz?<\/strong><\/em> diye sordu\u011funuzu duyar gibiyim&#8230; Biliyorsunuz ki, OpenID Connect kimlik do\u011frulama operasyonunu \u00fcstlenen bir katmand\u0131r. Dolay\u0131s\u0131yla kimlik do\u011frulama yap\u0131laca\u011f\u0131 noktada bu k\u00fct\u00fcphanenin y\u00fcklenmesi zaruridir.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-9.png\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"661\" height=\"164\" class=\"aligncenter size-full wp-image-18692\" srcset=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-9.png 661w, https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow-9-300x74.png 300w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/a><\/p>\n<p>Bildirilen paketi y\u00fckledikten sonra &#8216;Startup.cs&#8217; dosyas\u0131nda a\u015fa\u011f\u0131daki gibi Cookie ve OpenId konfig\u00fcrasyonlar\u0131n\u0131 yapmam\u0131z gerekmektedir.<\/p>\n<blockquote style=\"color:purple;\"><p><em>Access token client t\u00fcr\u00fcne g\u00f6re token yahut cookie olarak elde edilecektir. Client&#8217;\u0131n t\u00fcr\u00fc web uygulamas\u0131(MVC) ise cookie, server side(SPA, Mobile vs.) ise token olacakt\u0131r.<\/em><\/p><\/blockquote>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class Startup\r\n    {\r\n        public void ConfigureServices(IServiceCollection services)\r\n        {\r\n            .\r\n            .\r\n            .\r\n            services.AddAuthentication(_ =&gt;\r\n            {\r\n                _.DefaultScheme = &quot;OnlineBankamatikCookie&quot;;\r\n                _.DefaultChallengeScheme = &quot;oidc&quot;;\r\n            })\r\n            .AddCookie(&quot;OnlineBankamatikCookie&quot;)\r\n            .AddOpenIdConnect(&quot;oidc&quot;, _ =&gt;\r\n            {\r\n                _.SignInScheme = &quot;OnlineBankamatikCookie&quot;;\r\n                _.Authority = &quot;https:\/\/localhost:1000&quot;;\r\n                _.ClientId = &quot;OnlineBankamatik&quot;;\r\n                _.ClientSecret = &quot;onlinebankamatik&quot;;\r\n                _.ResponseType = &quot;code id_token&quot;;\r\n            });\r\n            .\r\n            .\r\n            .\r\n        }\r\n        .\r\n        .\r\n        .\r\n    }\r\n<\/pre>\n<p>Yukar\u0131da yap\u0131lan konfig\u00fcrasyonu incelersek e\u011fer; uygulamaya &#8216;AddAuthentication&#8217; metodu ile \u015fema isimleri herhangi bir de\u011fer olabilecek \u015fekilde authentication servisi eklenmekte, ard\u0131ndan &#8216;AddCookie&#8217; metoduyla cookie servisi ve yukar\u0131da y\u00fckledi\u011fimiz paket neticesinde gelen &#8216;AddOpenIdConnect&#8217; metodu arac\u0131l\u0131\u011f\u0131yla da OpenIdConnect protokol\u00fc dahil edilmektedir. Her ne kadar authentication k\u0131sm\u0131nda tan\u0131mlanan \u015femalar random bir isim olabilirsede, Cookie ve OpenIdConnect servislerinde kullan\u0131lan \u015femalar\u0131n s\u0131ras\u0131yla &#8216;DefaultScheme&#8217; ve &#8216;DefaultChallengeScheme&#8217; ile birebir ayn\u0131 olmas\u0131na \u00f6zen g\u00f6steriniz.<\/p>\n<p>OpenIdConnect metodu i\u00e7erisinde de\u011fer atanan alanlara gelirsek e\u011fer;<\/p>\n<ul>\n<li><em style=\"color:red;\">SignInScheme<\/em> : SignIn i\u015fleminin yapaca\u011f\u0131 \u015femay\u0131 temsil eder. &#8216;AddAuthentication&#8217; metodundaki &#8216;DefaultScheme&#8217; ile ayn\u0131 olmal\u0131d\u0131r.<\/li>\n<li><em style=\"color:red;\">Authority<\/em> : Yetkinin kimden al\u0131nd\u0131\u011f\u0131n\u0131 tutar. &#8216;AuthServer&#8217;\u0131n adresini belirtiyoruz.<\/li>\n<li><em style=\"color:red;\">ClientId<\/em> : Bu client&#8217;\u0131n &#8216;AuthServer&#8217;da ki Client_Id kar\u015f\u0131l\u0131\u011f\u0131.<\/li>\n<li><em style=\"color:red;\">ClientSecret<\/em> : Bu client&#8217;\u0131n &#8216;AuthServer&#8217;da ki Client_Secret kar\u015f\u0131l\u0131\u011f\u0131.<\/li>\n<li><em style=\"color:red;\">ResponseType<\/em> : Olu\u015fturulacak Authorization Code i\u00e7erisinde bulunmas\u0131n\u0131 istedi\u011fimiz datalar\u0131 belirtiyoruz. &#8216;code&#8217;, \u00fcretilecek olan authorize kodu ifade ederken, &#8216;id_token&#8217; ise access token&#8217;\u0131n bize ait olan Auth Server&#8217;dan gelip gelmedi\u011fini test etmek i\u00e7in \u00fcretilen bir de\u011ferdir. Bu konuyu sonraki makalelerimizde salt ba\u015fl\u0131k olarak de\u011ferlendirece\u011fiz.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Ad\u0131m 9<\/strong><br \/>\n\u015eimdi bir ad\u0131m \u00f6nce olu\u015fturulan client&#8217;\u0131n bilgilerine &#8216;AuthServer&#8217;da kar\u015f\u0131l\u0131k gelecek olan client&#8217;\u0131 tasarlayal\u0131m. Bunun i\u00e7in &#8216;Config.cs&#8217; dosyas\u0131nda yazm\u0131\u015f oldu\u011fumuz &#8216;GetClients&#8217; metodu i\u00e7erisinde a\u015fa\u011f\u0131daki kodu geli\u015ftirelim;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        public static IEnumerable&lt;Client&gt; GetClients()\r\n        {\r\n            return new List&lt;Client&gt;\r\n            {\r\n                         .\r\n                         .\r\n                         .\r\n                new Client\r\n                        {\r\n                            ClientId = &quot;OnlineBankamatik&quot;,\r\n                            ClientName = &quot;OnlineBankamatik&quot;,\r\n                            ClientSecrets = { new Secret(&quot;onlinebankamatik&quot;.Sha256()) },\r\n                            AllowedGrantTypes = GrantTypes.Hybrid,\r\n                            AllowedScopes = { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Profile },\r\n                            RedirectUris = { &quot;https:\/\/localhost:4000\/signin-oidc&quot; },\r\n                            RequirePkce = false\r\n                        }\r\n            };\r\n        }\r\n<\/pre>\n<p>Yukar\u0131daki client&#8217;a dair olu\u015fturulan kodlara g\u00f6z atarsak;<\/p>\n<p>&#8216;AllowedGrantTypes&#8217; property&#8217;sine atanan &#8216;GrantTypes.Hybrid&#8217; de\u011feri ile client&#8217;\u0131n &#8216;ResponseType&#8217;\u0131nda belirtti\u011fi &#8216;code&#8217; ve &#8216;id_token&#8217; de\u011ferlerini alabilecek bir grant type bildirilmektedir. Bir \u00f6nceki ad\u0131mda bildirdi\u011fimiz gibi &#8216;code&#8217; esas\u0131nda &#8216;Authorization Code Grant&#8217;a kar\u015f\u0131l\u0131k gelmekte ve sadece authorization code&#8217;u temsil etmektedir. &#8216;code id_token&#8217; gibi birden fazla ifadenin bir araya gelmi\u015f hali ise Hybrid olarak isimlendirilmekte ve burada &#8216;id_token&#8217; access token&#8217;\u0131n bize ait Auth Server&#8217;dan geldi\u011fini do\u011frulayacak kodu temsil etmektedir. Haliyle &#8216;GrantTypes.Hybrid&#8217; diyerek bu client&#8217;\u0131n authororization code ile birlikte access token&#8217;\u0131 elde etmek istedi\u011fi bildirilmektedir. <span style=\"font-size:11px;\">Bir \u00f6nceki ad\u0131mda bahsedildi\u011fi gibi bu Response Type konusu yaz\u0131 serimizin devam\u0131nda salt ba\u015fl\u0131k olarak detayl\u0131ca incelenecektir.<\/span><\/p>\n<p>Client&#8217;\u0131n kullan\u0131c\u0131 hakk\u0131nda elde edebilece\u011fi bilgileri ise &#8216;AllowedScopes&#8217; property&#8217;si \u00fczerinden bildirilmektedir.<\/p>\n<p>&#8216;RedirectUris&#8217; property&#8217;sine ise <code style=\"color:red;\">\/signin-oidc<\/code> adresi verilerek client&#8217;\u0131n yetkilendirme neticesinde hangi sayfas\u0131na y\u00f6nlendirilece\u011fi bildirilmektedir. Burada <code style=\"color:red;\">\/signin-oidc<\/code> adresinin nereden kaynakland\u0131\u011f\u0131n\u0131 ve ne zaman olu\u015fturuldu\u011funu merak edebilirsiniz. Bu OpenIdConnect paketi taraf\u0131ndan ilgili client&#8217;ta olu\u015fturulan hali haz\u0131rda bir adrestir. &#8216;AuthServer&#8217;, IdentityServer4 framework&#8217;\u00fc sayesinde client&#8217;ta ki bu adrese d\u00f6n\u00fc\u015f yapaca\u011f\u0131n\u0131 varsay\u0131lan olarak bilmekte ve \u00fcretilen token yahut cookie gibi de\u011ferleri bu adres \u00fczerinden servis etmektedir.<\/p>\n<p>Ve son olarak &#8216;RequirePkce&#8217; property&#8217;sini &#8216;false&#8217; yaparak ileride g\u00f6rece\u011fimiz (Proof Key For Code) yap\u0131lanmas\u0131n\u0131 devre d\u0131\u015f\u0131 b\u0131rak\u0131yoruz. Bu yap\u0131lanma client secret ve client id de\u011ferlerinin \u00e7al\u0131nmas\u0131na kar\u015f\u0131 al\u0131nm\u0131\u015f bir g\u00fcvenliksel stratejik \u00f6nlemdir.\n<\/li>\n<li><strong>Ad\u0131m 10<\/strong><br \/>\nClient&#8217;ta kullan\u0131c\u0131 i\u00e7in &#8216;BankamatikController&#8217; isminde farazi bir controller tasarlayal\u0131m ve a\u015fa\u011f\u0131daki gibi &#8216;OdemeYap&#8217; action&#8217;\u0131n\u0131 &#8216;Authorize&#8217; ederek yetkisiz eri\u015fimi engelleyelim.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    public class BankamatikController : Controller\r\n    {\r\n        public IActionResult Index()\r\n        {\r\n            return View();\r\n        }\r\n        &#x5B;Authorize]\r\n        public IActionResult OdemeYap()\r\n        {\r\n            return View();\r\n        }\r\n    }\r\n<\/pre>\n<\/li>\n<li><strong>Ad\u0131m 11<\/strong><br \/>\nVe son olarak geli\u015ftirilen bu client&#8217;da authentication ve authorization middleware&#8217;lerini \u00e7a\u011f\u0131ral\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            app.UseAuthentication();\r\n            app.UseAuthorization();\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>\u0130\u015fte bu kadar&#8230; \ud83d\ude42<\/p>\n<h4 style=\"color:purple;\">\u00d6rnek Uygulama Testi<\/h4>\n<p>\u015eimdi geli\u015ftirdi\u011fimiz bu \u00f6rnek uygulamay\u0131 topyek\u00fcn aya\u011fa kald\u0131rarak tam teferruatl\u0131 test edelim.<br \/>\n<a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/10\/IdentityServer4-Yazi-Serisi-8-Authorization-Code-GrantFlow.gif\" alt=\"IdentityServer4 Yaz\u0131 Serisi #8 - Authorization Code Grant(Flow)\" width=\"800\" height=\"538\" class=\"aligncenter size-full wp-image-18707\" \/><\/a><br \/>\nYukar\u0131daki ekran g\u00f6r\u00fcnt\u00fcs\u00fcnden de g\u00f6r\u00fcld\u00fc\u011f\u00fc \u00fczere testimiz ba\u015far\u0131yla sonu\u00e7lanm\u0131\u015f ve client authorization code&#8217;u cookie olarak alm\u0131\u015f bulunmaktad\u0131r. Dikkat ederseniz user, &#8216;OdemeYap&#8217; action&#8217;\u0131na eri\u015fmeye \u00e7al\u0131\u015ft\u0131\u011f\u0131 vakit &#8216;Authorize&#8217; attribute&#8217;u sayesinde yetkisiz kullan\u0131c\u0131 oldu\u011fu anla\u015f\u0131lmakta ve &#8216;AuthServer&#8217; adresindeki &#8216;login&#8217; sayfas\u0131na a\u015fa\u011f\u0131daki adres \u00fczerinden y\u00f6nlendirilmektedir.(<span style=\"font-size:11px;\">Ne yaz\u0131k ki ekran g\u00f6r\u00fcnt\u00fcs\u00fcn\u00fc al\u0131rken kullan\u0131lan Opera taray\u0131c\u0131s\u0131 query string de\u011ferlerini g\u00f6rmemizi engellemektedir.<\/span>)<\/p>\n<p style=\"color:red;line-height:20px;font-size:10px;\">https:\/\/localhost:1000\/Account\/Login?ReturnUrl=%2Fconnect%2Fauthorize%2Fcallback%3Fclient_id%3DOnlineBankamatik%26redirect_uri<br \/>\n%3Dhttps%253A%252F%252Flocalhost%253A4000%252Fsignin-oidc%26response_type%3Dcode%2520id_token%26scope%3Dopenid%2520profile%26response_mode%3Dform_post%26nonce%3D637396<br \/>\n630618971508.ZWEyNjYzNTAtMmYyNS00OGEyLThhOGEtMjY4ZDk1ZjlkMjU1NGM4OWQ0MmMtMGEz<br \/>\nOC00MzhlLWEyNTEtMWIxYjJmNmNiYzAx%26state%3DCfDJ8MUlvpM_ov1Il6SbMbgfypVc7I_<br \/>\nCgt3Ld5pnDRb1gWJfV371PJnQKk_UcLTSqYcxHgXn4gsPZl3Y3GV-VaDCSYkT8a9poiM1nPvMRprJzoxy_4EhZvkZRQR7JEFIp7K5HLT7Q_lEj5Zsm4Ead02luApp9bE8BR_6YyhMchH7u7c2amvUEgH<br \/>\nsZ65l0-zQH6jqGg2BXaLKK-hoqSXYGFpCMRgveuVIgyomL1P9wM7nAJ2Al8T9PmXlvXvOLCBrPyHfuOca1-DZ9MDiNgFps9TO0YJ82r5qJrYhv81XUq2qFgXE-hC6Aiz0o<br \/>\n213O9R5JkuoIw%26x-client-SKU%3DID_NETSTANDARD2_0%26x-client-ver%3D5.5.0.0<\/p>\n<p>Kullan\u0131c\u0131 bilgilerini giren kullan\u0131c\u0131 onayland\u0131ktan sonra tekrar &#8216;AuthServer&#8217; taraf\u0131ndan ilgili client&#8217;a &#8216;idsrv&#8217; ad\u0131 alt\u0131nda bir cookie ile y\u00f6nlendirilmekte ve eri\u015fim sa\u011flanmaktad\u0131r.<\/p>\n<p>Evet&#8230; B\u00f6ylece client &#8216;AuthServer&#8217;dan yetki(authorization code) alm\u0131\u015f bulunmaktad\u0131r. Bundan sonra bu authorization code&#8217;u kullanarak kullan\u0131c\u0131ya dair claim&#8217;leri okuyabilir, access token, refresh token, id token vs. gibi bilgileri elde edebilir ve API&#8217;lara isteklerde bulunabiliriz. <\/p>\n<p>Tabi ki de bu i\u015flemleri sonraki makalelere b\u0131rak\u0131yorum \ud83d\ude42<\/p>\n<p>\u0130lgilenenlerin faydalanmas\u0131 dile\u011fiyle&#8230;<br \/>\nSonraki yaz\u0131lar\u0131mda g\u00f6r\u00fc\u015fmek \u00fczere&#8230;<br \/>\n\u0130yi \u00e7al\u0131\u015fmalar&#8230;<\/p>\n<p>Not : \u00d6rnek uygulamay\u0131 indirmek i\u00e7in <a href=\"https:\/\/www.gencayyildiz.com\/blog\/wp-content\/uploads\/2020\/11\/IdentityServer4Example.zip\">buraya<\/a> t\u0131klay\u0131n\u0131z.<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Merhaba, Bu i\u00e7eri\u011fimizde yaz\u0131 serimiz boyunca ara ara geli\u015ftirdi\u011fimiz \u00f6rnek uygulama \u00fczerinden Merkezi \u00dcyelik Sistemi&#8217;ni \u00f6rneklendirece\u011fiz. Geli\u015ftirdi\u011fimiz uygulaman\u0131n bu makaleye kadar olan en son halini elde edebilmek i\u00e7in buraya t\u0131klay\u0131n\u0131z. \u015eimdi Merkezi \u00dcyelik Sistemi&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":18168,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3826],"tags":[3827,3888,3887],"class_list":["post-18730","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-identityserver4","tag-identityserver4","tag-identityserver4-merkezi-uyelik-sistemi","tag-merkezi-uyelik-sistemi"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/18730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=18730"}],"version-history":[{"count":15,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/18730\/revisions"}],"predecessor-version":[{"id":18834,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/18730\/revisions\/18834"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media\/18168"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=18730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=18730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=18730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}