Skip to content

Commit

Permalink
Ticket ## : Fix authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed May 3, 2021
1 parent 50db72d commit 3951f1b
Show file tree
Hide file tree
Showing 21 changed files with 201 additions and 61 deletions.
30 changes: 26 additions & 4 deletions src/CaseManagement.BPMN.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
});
Expand Down Expand Up @@ -97,11 +97,33 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}
}
}
4 changes: 2 additions & 2 deletions src/CaseManagement.BPMN.Host/openid_puk.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
"e":"AQAB"
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
"e": "AQAB"
}
30 changes: 26 additions & 4 deletions src/CaseManagement.BPMN.SqlServer.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
});
Expand Down Expand Up @@ -120,8 +120,8 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
Expand Down Expand Up @@ -151,5 +151,27 @@ private void InitializeDatabase(IApplicationBuilder app)
}
}
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}
}
}
4 changes: 2 additions & 2 deletions src/CaseManagement.BPMN.SqlServer.Host/openid_puk.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
"e":"AQAB"
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
"e": "AQAB"
}
32 changes: 27 additions & 5 deletions src/CaseManagement.CMMN.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
})
Expand All @@ -68,7 +68,7 @@ public void ConfigureServices(IServiceCollection services)
ValidIssuers = new List<string>
{
"http://localhost:60001",
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
}
};
});
Expand Down Expand Up @@ -173,11 +173,33 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}
}
}
4 changes: 2 additions & 2 deletions src/CaseManagement.CMMN.Host/openid_puk.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
"e":"AQAB"
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
"e": "AQAB"
}
32 changes: 27 additions & 5 deletions src/CaseManagement.CMMN.SqlServer.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
})
Expand All @@ -78,7 +78,7 @@ public void ConfigureServices(IServiceCollection services)
ValidIssuers = new List<string>
{
"http://localhost:60001",
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
}
};
});
Expand Down Expand Up @@ -192,13 +192,35 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}

private void InitializeDatabase(IApplicationBuilder app)
{
var pathLst = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "Cmmns"), "*.cmmn").ToList();
Expand Down
4 changes: 2 additions & 2 deletions src/CaseManagement.CMMN.SqlServer.Host/openid_puk.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
"e":"AQAB"
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
"e": "AQAB"
}
32 changes: 27 additions & 5 deletions src/CaseManagement.HumanTask.EF.Startup/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
})
Expand All @@ -73,7 +73,7 @@ public void ConfigureServices(IServiceCollection services)
ValidIssuers = new List<string>
{
"http://localhost:60001",
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
}
};
}); ;
Expand Down Expand Up @@ -118,8 +118,8 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
Expand Down Expand Up @@ -196,5 +196,27 @@ private static List<HumanTaskDefinitionAggregate> GetHumanTaskDefs()
updateClaimantContactDetailsForm
};
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}
}
}
4 changes: 2 additions & 2 deletions src/CaseManagement.HumanTask.EF.Startup/openid_puk.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
"e":"AQAB"
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
"e": "AQAB"
}
32 changes: 27 additions & 5 deletions src/CaseManagement.HumanTask.Host/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public void ConfigureServices(IServiceCollection services)
ValidAudiences = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
},
ValidIssuers = new List<string>
{
"http://localhost:60000",
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
}
};
})
Expand All @@ -108,7 +108,7 @@ public void ConfigureServices(IServiceCollection services)
ValidIssuers = new List<string>
{
"http://localhost:60001",
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
}
};
});
Expand Down Expand Up @@ -167,11 +167,33 @@ private RsaSecurityKey ExtractKey(string fileName)
var rsa = RSA.Create();
var rsaParameters = new RSAParameters
{
Modulus = Convert.FromBase64String(dic["n"].ToString()),
Exponent = Convert.FromBase64String(dic["e"].ToString())
Modulus = Base64DecodeBytes(dic["n"].ToString()),
Exponent = Base64DecodeBytes(dic["e"].ToString())
};
rsa.ImportParameters(rsaParameters);
return new RsaSecurityKey(rsa);
}

private static byte[] Base64DecodeBytes(string base64EncodedData)
{
var s = base64EncodedData
.Trim()
.Replace(" ", "+")
.Replace('-', '+')
.Replace('_', '/');
switch (s.Length % 4)
{
case 0:
return Convert.FromBase64String(s);
case 2:
s += "==";
goto case 0;
case 3:
s += "=";
goto case 0;
default:
throw new InvalidOperationException("Illegal base64url string!");
}
}
}
}

0 comments on commit 3951f1b

Please sign in to comment.