{"id":1963,"date":"2007-05-24T08:00:00","date_gmt":"2007-05-24T08:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/cesardelatorre\/2007\/05\/24\/how-to-use-cardspace-to-secure-web-applications\/"},"modified":"2007-05-24T08:00:00","modified_gmt":"2007-05-24T08:00:00","slug":"how-to-use-cardspace-to-secure-web-applications","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/how-to-use-cardspace-to-secure-web-applications\/","title":{"rendered":"How to use CardSpace to secure web applications"},"content":{"rendered":"<p><P>Using <STRONG>CardSpace<\/STRONG> to secure a Web Application&#8230;, that sounds interesting&#8230; We can also use CardSpace for securing WCF-Services for SOA application, but I leave that for another posting. :-). <BR>For a Web Application, we need to implement CardSpace within the Login and registration page, because we\u2019ll use it as an Authentication method.<BR>So, let\u2019s suppose we have a registration page called Registration.aspx. We\u2019ll have to embedded \u2018something\u2019 into the HTML so the browser can know how to trigger CardSpace secure environment (the credentials selector). So, what can it be?. Well, we\u2019ve got at least two choices: <BR>&#8211;&nbsp;A.- The <STRONG>CardSpace ActiveX Control<\/STRONG> which defines the requirements for our CardSpace implementation.<BR>&#8211;&nbsp;B.- An \u2018<STRONG>XHTML binary behavior<\/STRONG>&#8216; for <STRONG>CardSpace<\/STRONG> describing the information card requirements. I&#8217;d use this option for non-IE browsers, like <EM>FireFox<\/EM>, etc.<BR>In either case, we\u2019ll have to describe what are the InformationCard requirements. The two most important parameters are:<BR>&#8211;&nbsp;<STRONG>Token Type<\/STRONG>: It tells to CardSpace user interface to prompt only with cards that represent this type of token.<BR>&#8211;&nbsp;<STRONG>Claims<\/STRONG>: Claims that must be passed in the security token containing the user\u2019s identity. In this case, we require just \u2018required claims\u2019, but a user could also choose to send optional claim information as well, so it will also provide things like name, surname, address, or any other type of claim.<BR>If we use a <STRONG>CardSpace ActiveX Control<\/STRONG>, it would be something like:<\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\">&lt;object type=&#8221;application\/x-informationcard&#8221; name=&#8221;xmlToken&#8221; id=&#8221;xmlToken&#8221;&gt;<SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp;&nbsp; <\/SPAN>&lt;param name=&#8221;<B>tokenType<\/B>&#8221; value=&#8221;urn:oasis:names:tc:SAML:1.0:assertion&#8221; \/&gt;<SPAN> <\/SPAN><SPAN>&nbsp; <\/SPAN><\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&nbsp;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp;&nbsp; <\/SPAN>&lt;param name=&#8221;<B>requiredClaims<\/B>&#8221; value=&#8221;http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/givenname http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/surname http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/emailaddress http:\/\/schemas.xmlsoap.org\/ws\/2005\/05\/identity\/claims\/privatepersonalidentifier&#8221; \/&gt;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\">&lt;object\/&gt;<\/FONT><\/FONT><\/SPAN><\/P>\n<P>On the other hand, if we use a \u2018XHTML binary behavior&#8217;, it would be something similar to:<\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;!DOCTYPE html PUBLIC &#8220;-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN&#8221; &#8220;http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd&#8221;&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221; xmlns:ic&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;head&gt;&lt;title&gt;My Web-Site&lt;\/title&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;link xhref=&#8221;App_Themes\/site_styles.css&#8221; mce_href=&#8221;App_Themes\/site_styles.css&#8221; rel=&#8221;stylesheet&#8221; type=&#8221;text\/css&#8221; \/&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&nbsp;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\">&lt;<B>ic:informationcard<\/B><\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp; <\/SPAN>id=&#8217;infocardBehavior&#8217;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp; <\/SPAN>name=&#8217;infocardBehavior&#8217;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp; <\/SPAN>style=&#8217;behavior: url(#default#informationCard)&#8217;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp; <\/SPAN>issuer=&#8217;http:\/\/sts.labs.live.com\/trust\/InfoCard&#8217;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT><FONT face=\"Courier New\"><SPAN>&nbsp; <\/SPAN>tokenType=&#8217;http:\/\/docs.oasis-open.org\/wss\/oasis-wss-saml-token-profile-1.1#SAMLV1.1&#8242;&gt;<\/FONT><\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;ic:add claimtype=&#8217;http:\/\/schemas.microsoft.com\/ws\/2005\/05\/identity\/claims\/privatepersonalidentifier&#8217; optional=&#8217;false&#8217; \/&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;\/ic:informationcard&gt;<\/FONT><\/SPAN><\/P>\n<P class=\"MSLabCode\"><SPAN lang=\"EN-US\"><FONT face=\"Courier New\">&lt;\/head&gt;<\/FONT><\/SPAN><\/P>\n<P>Take into account that usually, you need something more than just single auto-assigned information cards. If you really want to authenticate, you need to do it against any user credentials repository, right?. Well, it depends of our environment, but usually we\u2019ll have two typical ways of &#8216;how to authenticate&#8217;:<\/P>\n<P><BR>A. &#8211; Use auto self assigned information cards and then, when the user is registering itself, we can create a Membership user, so, we can associate the <STRONG>card-id<\/STRONG> with the <STRONG>Membership user id<\/STRONG> we&#8217;ve just created.<BR>B.- The second way is, of course, involving an &#8216;<STRONG>Identity Provider<\/STRONG>&#8216; in our system, using a <STRONG>STS<\/STRONG> (<EM>Security Token Service<\/EM>) which will be the external authority or &#8216;<STRONG>Identity Provider<\/STRONG>&#8216; assigning security tokens (any kind), and then, the <STRONG>Relying party<\/STRONG> (your web application)&nbsp;should also authenticate that security token agaist any type of user credentials repository (<EM>Active Directory Federation Services<\/EM>, <EM>Membership<\/EM>, or any other kind).<\/P>\n<P><BR>So!, it is not a really complicated thing, but you have to consider different choices and getting the best from different worlds (HTML, Script and .NET executing at the server).<BR>Read the following articles&nbsp;for a deeper&nbsp;scuba-diving&nbsp;in CardSpace:<BR><STRONG>Secure Your ASP.NET Apps And WCF Services With Windows CardSpace<\/STRONG><\/P>\n<P><SPAN lang=\"EN-US\"><A href=\"http:\/\/msdn.microsoft.com\/msdnmag\/issues\/07\/04\/identity\/\">http:\/\/msdn.microsoft.com\/msdnmag\/issues\/07\/04\/identity\/<\/A><\/SPAN><\/P>\n<P><STRONG>How to Use Windows CardSpace with Internet Explorer 7.0<\/STRONG><\/P>\n<P><A href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa395199.aspx\">http:\/\/msdn2.microsoft.com\/en-us\/library\/aa395199.aspx<\/A><\/P>\n<P>and also: <A href=\"http:\/\/cardspace.netfx3.com\/\">http:\/\/cardspace.netfx3.com\/<\/A><\/P>\n<P>Interesting, uh? \ud83d\ude42<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using CardSpace to secure a Web Application&#8230;, that sounds interesting&#8230; We can also use CardSpace for securing WCF-Services for SOA application, but I leave that for another posting. :-). For a Web Application, we need to implement CardSpace within the Login and registration page, because we\u2019ll use it as an Authentication method.So, let\u2019s suppose we [&hellip;]<\/p>\n","protected":false},"author":362,"featured_media":12806,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[35],"class_list":["post-1963","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cesardelatorre","tag-cardspace"],"acf":[],"blog_post_summary":"<p>Using CardSpace to secure a Web Application&#8230;, that sounds interesting&#8230; We can also use CardSpace for securing WCF-Services for SOA application, but I leave that for another posting. :-). For a Web Application, we need to implement CardSpace within the Login and registration page, because we\u2019ll use it as an Authentication method.So, let\u2019s suppose we [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/1963","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/comments?post=1963"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/posts\/1963\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media\/12806"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/media?parent=1963"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/categories?post=1963"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cesardelatorre\/wp-json\/wp\/v2\/tags?post=1963"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}