{"id":1434,"date":"2015-01-29T20:33:46","date_gmt":"2015-01-30T02:33:46","guid":{"rendered":"https:\/\/www.identityblog.com\/?page_id=1434"},"modified":"2015-01-30T15:54:27","modified_gmt":"2015-01-30T21:54:27","slug":"hash-transform","status":"publish","type":"page","link":"https:\/\/www.identityblog.com\/?page_id=1434","title":{"rendered":"Hash Claims Transformation"},"content":{"rendered":"<div>The Hash claims transformation provides the ability to create an output\u00a0claim which is the hash of an\u00a0input claim. Salt\u00a0must be added using a second input claim and an input parameter. \u00a0The input parameter\u00a0must be the name of a secret key belonging to the tenant\u00a0so that\u00a0publication of the policy doesn&#8217;t allow an attacker to predict the value of the hash\u00a0by virtue of knowing the input claims.<\/div>\n<p>&nbsp;<\/p>\n<div>\n<table style=\"border-collapse: collapse; background: #e2efd9;\" border=\"0\">\n<colgroup>\n<col style=\"width: 615px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr>\n<td style=\"padding-left: 9px; padding-right: 9px; border: solid #bfbfbf 0.5pt;\">\n<p style=\"text-align: center;\"><span style=\"font-size: 12pt;\"><strong>InputClaims<\/strong><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse;\" border=\"0\">\n<colgroup>\n<col style=\"width: 277px;\" \/>\n<col style=\"width: 338px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr style=\"background: white;\">\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>TransformationClaimType<\/em><\/span><\/p>\n<\/td>\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\"><span style=\"font-size: 13pt;\"><em>Description<\/em><\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"background: white; padding-left: 9px; padding-right: 9px; border-right: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>plaintext<\/em><\/span><\/p>\n<\/td>\n<td style=\"background: #f2f2f2; padding-left: 9px; padding-right: 9px;\">The string to hash<\/td>\n<\/tr>\n<tr>\n<td style=\"background: white; padding-left: 9px; padding-right: 9px; border-right: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>salt<\/em><\/span><\/p>\n<\/td>\n<td style=\"padding-left: 9px; padding-right: 9px;\">The optional salt for the hash<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse; background: #e2efd9;\" border=\"0\">\n<colgroup>\n<col style=\"width: 615px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr>\n<td style=\"padding-left: 9px; padding-right: 9px; border: solid #bfbfbf 0.5pt;\">\n<p style=\"text-align: center;\"><span style=\"font-size: 12pt;\"><strong>InputParameters<\/strong><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse;\" border=\"0\">\n<colgroup>\n<col style=\"width: 176px;\" \/>\n<col style=\"width: 169px;\" \/>\n<col style=\"width: 278px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr style=\"background: white;\">\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>Id<\/em><\/span><\/p>\n<\/td>\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\"><span style=\"font-size: 13pt;\"><em>DataType<\/em><\/span><\/td>\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\"><span style=\"font-size: 13pt;\"><em>Value<\/em><\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"background: white; padding-left: 9px; padding-right: 9px; border-right: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>randomizerSecret<\/em><\/span><\/p>\n<\/td>\n<td style=\"background: #f2f2f2; padding-left: 9px; padding-right: 9px;\">string<\/td>\n<td style=\"background: #f2f2f2; padding-left: 9px; padding-right: 9px;\">The name of a tenant key<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse; background: #e2efd9;\" border=\"0\">\n<colgroup>\n<col style=\"width: 615px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr>\n<td style=\"padding-left: 9px; padding-right: 9px; border: solid #bfbfbf 0.5pt;\">\n<p style=\"text-align: center;\"><span style=\"font-size: 12pt;\"><strong>OutputClaims<\/strong><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse;\" border=\"0\">\n<colgroup>\n<col style=\"width: 277px;\" \/>\n<col style=\"width: 338px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr style=\"background: white;\">\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>TransformationClaimType<\/em><\/span><\/p>\n<\/td>\n<td style=\"padding-left: 9px; padding-right: 9px; border-bottom: solid #7f7f7f 0.5pt;\"><span style=\"font-size: 13pt;\"><em>Description<\/em><\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"background: white; padding-left: 9px; padding-right: 9px; border-right: solid #7f7f7f 0.5pt;\">\n<p style=\"text-align: right;\"><span style=\"font-size: 13pt;\"><em>hash<\/em><\/span><\/p>\n<\/td>\n<td style=\"background: #f2f2f2; padding-left: 9px; padding-right: 9px;\">The hash computed by the transformation<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<table style=\"border-collapse: collapse; background: #e2efd9;\" border=\"0\">\n<colgroup>\n<col style=\"width: 615px;\" \/><\/colgroup>\n<tbody valign=\"top\">\n<tr>\n<td style=\"padding-left: 9px; padding-right: 9px; border: solid #bfbfbf 0.5pt;\">\n<p style=\"text-align: center;\"><span style=\"font-size: 12pt;\"><strong>Example<\/strong><\/span><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div>\n<p>This example defines a ClaimsTransformation of the &#8216;Hash&#8217; type called &#8216;HashPasswordWithUserId&#8217;. A claim called &#8216;password&#8217; in the policy schema is hashed using a claim called &#8216;userId&#8217; as salt. Because the hash is salted this way, two users with different userIds but the same password always end up with different hashes. This makes it impossible for an evil insider to insert the hash of a password he knows into another user&#8217;s record and successfully log in as the second user.<\/p>\n<p>In addition, the InputParameters statement causes the password to be salted by a secret key created by the tenant called, in this case, &#8216;AccountTransformSecret&#8217;. This means that even if two tenants have users with the same userIds and passwords, the hashes produced will be different. Further, it will be impossible to play passwords for a given userId against a known hash in order to discover the password.<\/p>\n<p>The output of the transformation is put into a claim called &#8216;hashedPassword&#8217; in the policy schema.<\/p>\n<\/div>\n<p><!-- code formatted by http:\/\/manoli.net\/csharpformat\/ --><\/p>\n<pre class=\"csharpcode\">      \r\n<span class=\"kwrd\">&lt;<\/span><span class=\"html\">ClaimsTransformation<\/span> <span class=\"attr\">Id<\/span><span class=\"kwrd\">=\"HashPasswordWithUserId\"<\/span> <span class=\"attr\">TransformationMethod<\/span><span class=\"kwrd\">=\"Hash\"<\/span><span class=\"kwrd\">&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;<\/span><span class=\"html\">InputClaims<\/span><span class=\"kwrd\">&gt;<\/span>\r\n          <span class=\"kwrd\">&lt;<\/span><span class=\"html\">InputClaim<\/span> <span class=\"attr\">ClaimTypeReferenceId<\/span><span class=\"kwrd\">=\"password\"<\/span> <span class=\"attr\">TransformationClaimType<\/span><span class=\"kwrd\">=\"plaintext\"<\/span> <span class=\"kwrd\">\/&gt;<\/span>\r\n          <span class=\"kwrd\">&lt;<\/span><span class=\"html\">InputClaim<\/span> <span class=\"attr\">ClaimTypeReferenceId<\/span><span class=\"kwrd\">=\"userId\"<\/span> <span class=\"attr\">TransformationClaimType<\/span><span class=\"kwrd\">=\"salt\"<\/span> <span class=\"kwrd\">\/&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;\/<\/span><span class=\"html\">InputClaims<\/span><span class=\"kwrd\">&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;<\/span><span class=\"html\">InputParameters<\/span><span class=\"kwrd\">&gt;<\/span>\r\n          <span class=\"kwrd\">&lt;<\/span><span class=\"html\">InputParameter<\/span> <span class=\"attr\">Id<\/span><span class=\"kwrd\">=\"randomizerSecret\"<\/span> <span class=\"attr\">DataType<\/span><span class=\"kwrd\">=\"string\"<\/span> <span class=\"attr\">Value<\/span><span class=\"kwrd\">=\"AccountTransformSecret\"<\/span> <span class=\"kwrd\">\/&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;\/<\/span><span class=\"html\">InputParameters<\/span><span class=\"kwrd\">&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;<\/span><span class=\"html\">OutputClaims<\/span><span class=\"kwrd\">&gt;<\/span>\r\n          <span class=\"kwrd\">&lt;<\/span><span class=\"html\">OutputClaim<\/span> <span class=\"attr\">ClaimTypeReferenceId<\/span><span class=\"kwrd\">=\"hashedPassword\"<\/span> <span class=\"attr\">TransformationClaimType<\/span><span class=\"kwrd\">=\"hash\"<\/span> <span class=\"kwrd\">\/&gt;<\/span>\r\n        <span class=\"kwrd\">&lt;\/<\/span><span class=\"html\">OutputClaims<\/span><span class=\"kwrd\">&gt;<\/span>\r\n      <span class=\"kwrd\">&lt;\/<\/span><span class=\"html\">ClaimsTransformation<\/span><span class=\"kwrd\">&gt;<\/span>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Hash claims transformation provides the ability to create an output\u00a0claim which is the hash of an\u00a0input claim. Salt\u00a0must be added using a second input claim and an input parameter. \u00a0The input parameter\u00a0must be the name of a secret key belonging to the tenant\u00a0so that\u00a0publication of the policy doesn&#8217;t allow an attacker to predict the &hellip; <a href=\"https:\/\/www.identityblog.com\/?page_id=1434\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Hash Claims Transformation<\/span><\/a><\/p>\n","protected":false},"author":68,"featured_media":0,"parent":1453,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/pages\/1434"}],"collection":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1434"}],"version-history":[{"count":13,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/pages\/1434\/revisions"}],"predecessor-version":[{"id":1452,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/pages\/1434\/revisions\/1452"}],"up":[{"embeddable":true,"href":"https:\/\/www.identityblog.com\/index.php?rest_route=\/wp\/v2\/pages\/1453"}],"wp:attachment":[{"href":"https:\/\/www.identityblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}