Skip to content

Commit 3951f1b

Browse files
Ticket ## : Fix authentication
1 parent 50db72d commit 3951f1b

21 files changed

Lines changed: 201 additions & 61 deletions

File tree

src/CaseManagement.BPMN.Host/Startup.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ public void ConfigureServices(IServiceCollection services)
4646
ValidAudiences = new List<string>
4747
{
4848
"http://localhost:60000",
49-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
49+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
5050
},
5151
ValidIssuers = new List<string>
5252
{
5353
"http://localhost:60000",
54-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
54+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
5555
}
5656
};
5757
});
@@ -97,11 +97,33 @@ private RsaSecurityKey ExtractKey(string fileName)
9797
var rsa = RSA.Create();
9898
var rsaParameters = new RSAParameters
9999
{
100-
Modulus = Convert.FromBase64String(dic["n"].ToString()),
101-
Exponent = Convert.FromBase64String(dic["e"].ToString())
100+
Modulus = Base64DecodeBytes(dic["n"].ToString()),
101+
Exponent = Base64DecodeBytes(dic["e"].ToString())
102102
};
103103
rsa.ImportParameters(rsaParameters);
104104
return new RsaSecurityKey(rsa);
105105
}
106+
107+
private static byte[] Base64DecodeBytes(string base64EncodedData)
108+
{
109+
var s = base64EncodedData
110+
.Trim()
111+
.Replace(" ", "+")
112+
.Replace('-', '+')
113+
.Replace('_', '/');
114+
switch (s.Length % 4)
115+
{
116+
case 0:
117+
return Convert.FromBase64String(s);
118+
case 2:
119+
s += "==";
120+
goto case 0;
121+
case 3:
122+
s += "=";
123+
goto case 0;
124+
default:
125+
throw new InvalidOperationException("Illegal base64url string!");
126+
}
127+
}
106128
}
107129
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
3-
"e":"AQAB"
2+
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
3+
"e": "AQAB"
44
}

src/CaseManagement.BPMN.SqlServer.Host/Startup.cs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public void ConfigureServices(IServiceCollection services)
5656
ValidAudiences = new List<string>
5757
{
5858
"http://localhost:60000",
59-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
59+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
6060
},
6161
ValidIssuers = new List<string>
6262
{
6363
"http://localhost:60000",
64-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
64+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
6565
}
6666
};
6767
});
@@ -120,8 +120,8 @@ private RsaSecurityKey ExtractKey(string fileName)
120120
var rsa = RSA.Create();
121121
var rsaParameters = new RSAParameters
122122
{
123-
Modulus = Convert.FromBase64String(dic["n"].ToString()),
124-
Exponent = Convert.FromBase64String(dic["e"].ToString())
123+
Modulus = Base64DecodeBytes(dic["n"].ToString()),
124+
Exponent = Base64DecodeBytes(dic["e"].ToString())
125125
};
126126
rsa.ImportParameters(rsaParameters);
127127
return new RsaSecurityKey(rsa);
@@ -151,5 +151,27 @@ private void InitializeDatabase(IApplicationBuilder app)
151151
}
152152
}
153153
}
154+
155+
private static byte[] Base64DecodeBytes(string base64EncodedData)
156+
{
157+
var s = base64EncodedData
158+
.Trim()
159+
.Replace(" ", "+")
160+
.Replace('-', '+')
161+
.Replace('_', '/');
162+
switch (s.Length % 4)
163+
{
164+
case 0:
165+
return Convert.FromBase64String(s);
166+
case 2:
167+
s += "==";
168+
goto case 0;
169+
case 3:
170+
s += "=";
171+
goto case 0;
172+
default:
173+
throw new InvalidOperationException("Illegal base64url string!");
174+
}
175+
}
154176
}
155177
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
3-
"e":"AQAB"
2+
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
3+
"e": "AQAB"
44
}

src/CaseManagement.CMMN.Host/Startup.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ public void ConfigureServices(IServiceCollection services)
4747
ValidAudiences = new List<string>
4848
{
4949
"http://localhost:60000",
50-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
50+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
5151
},
5252
ValidIssuers = new List<string>
5353
{
5454
"http://localhost:60000",
55-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
55+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
5656
}
5757
};
5858
})
@@ -68,7 +68,7 @@ public void ConfigureServices(IServiceCollection services)
6868
ValidIssuers = new List<string>
6969
{
7070
"http://localhost:60001",
71-
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
71+
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
7272
}
7373
};
7474
});
@@ -173,11 +173,33 @@ private RsaSecurityKey ExtractKey(string fileName)
173173
var rsa = RSA.Create();
174174
var rsaParameters = new RSAParameters
175175
{
176-
Modulus = Convert.FromBase64String(dic["n"].ToString()),
177-
Exponent = Convert.FromBase64String(dic["e"].ToString())
176+
Modulus = Base64DecodeBytes(dic["n"].ToString()),
177+
Exponent = Base64DecodeBytes(dic["e"].ToString())
178178
};
179179
rsa.ImportParameters(rsaParameters);
180180
return new RsaSecurityKey(rsa);
181181
}
182+
183+
private static byte[] Base64DecodeBytes(string base64EncodedData)
184+
{
185+
var s = base64EncodedData
186+
.Trim()
187+
.Replace(" ", "+")
188+
.Replace('-', '+')
189+
.Replace('_', '/');
190+
switch (s.Length % 4)
191+
{
192+
case 0:
193+
return Convert.FromBase64String(s);
194+
case 2:
195+
s += "==";
196+
goto case 0;
197+
case 3:
198+
s += "=";
199+
goto case 0;
200+
default:
201+
throw new InvalidOperationException("Illegal base64url string!");
202+
}
203+
}
182204
}
183205
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
3-
"e":"AQAB"
2+
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
3+
"e": "AQAB"
44
}

src/CaseManagement.CMMN.SqlServer.Host/Startup.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public void ConfigureServices(IServiceCollection services)
5757
ValidAudiences = new List<string>
5858
{
5959
"http://localhost:60000",
60-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
60+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
6161
},
6262
ValidIssuers = new List<string>
6363
{
6464
"http://localhost:60000",
65-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
65+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
6666
}
6767
};
6868
})
@@ -78,7 +78,7 @@ public void ConfigureServices(IServiceCollection services)
7878
ValidIssuers = new List<string>
7979
{
8080
"http://localhost:60001",
81-
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
81+
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
8282
}
8383
};
8484
});
@@ -192,13 +192,35 @@ private RsaSecurityKey ExtractKey(string fileName)
192192
var rsa = RSA.Create();
193193
var rsaParameters = new RSAParameters
194194
{
195-
Modulus = Convert.FromBase64String(dic["n"].ToString()),
196-
Exponent = Convert.FromBase64String(dic["e"].ToString())
195+
Modulus = Base64DecodeBytes(dic["n"].ToString()),
196+
Exponent = Base64DecodeBytes(dic["e"].ToString())
197197
};
198198
rsa.ImportParameters(rsaParameters);
199199
return new RsaSecurityKey(rsa);
200200
}
201201

202+
private static byte[] Base64DecodeBytes(string base64EncodedData)
203+
{
204+
var s = base64EncodedData
205+
.Trim()
206+
.Replace(" ", "+")
207+
.Replace('-', '+')
208+
.Replace('_', '/');
209+
switch (s.Length % 4)
210+
{
211+
case 0:
212+
return Convert.FromBase64String(s);
213+
case 2:
214+
s += "==";
215+
goto case 0;
216+
case 3:
217+
s += "=";
218+
goto case 0;
219+
default:
220+
throw new InvalidOperationException("Illegal base64url string!");
221+
}
222+
}
223+
202224
private void InitializeDatabase(IApplicationBuilder app)
203225
{
204226
var pathLst = Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "Cmmns"), "*.cmmn").ToList();
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
3-
"e":"AQAB"
2+
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
3+
"e": "AQAB"
44
}

src/CaseManagement.HumanTask.EF.Startup/Startup.cs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ public void ConfigureServices(IServiceCollection services)
5151
ValidAudiences = new List<string>
5252
{
5353
"http://localhost:60000",
54-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
54+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
5555
},
5656
ValidIssuers = new List<string>
5757
{
5858
"http://localhost:60000",
59-
"http://simpleidserver.northeurope.cloudapp.azure.com/openid"
59+
"https://simpleidserver.northeurope.cloudapp.azure.com/openid"
6060
}
6161
};
6262
})
@@ -73,7 +73,7 @@ public void ConfigureServices(IServiceCollection services)
7373
ValidIssuers = new List<string>
7474
{
7575
"http://localhost:60001",
76-
"http://simpleidserver.northeurope.cloudapp.azure.com/oauth"
76+
"https://simpleidserver.northeurope.cloudapp.azure.com/oauth"
7777
}
7878
};
7979
}); ;
@@ -118,8 +118,8 @@ private RsaSecurityKey ExtractKey(string fileName)
118118
var rsa = RSA.Create();
119119
var rsaParameters = new RSAParameters
120120
{
121-
Modulus = Convert.FromBase64String(dic["n"].ToString()),
122-
Exponent = Convert.FromBase64String(dic["e"].ToString())
121+
Modulus = Base64DecodeBytes(dic["n"].ToString()),
122+
Exponent = Base64DecodeBytes(dic["e"].ToString())
123123
};
124124
rsa.ImportParameters(rsaParameters);
125125
return new RsaSecurityKey(rsa);
@@ -196,5 +196,27 @@ private static List<HumanTaskDefinitionAggregate> GetHumanTaskDefs()
196196
updateClaimantContactDetailsForm
197197
};
198198
}
199+
200+
private static byte[] Base64DecodeBytes(string base64EncodedData)
201+
{
202+
var s = base64EncodedData
203+
.Trim()
204+
.Replace(" ", "+")
205+
.Replace('-', '+')
206+
.Replace('_', '/');
207+
switch (s.Length % 4)
208+
{
209+
case 0:
210+
return Convert.FromBase64String(s);
211+
case 2:
212+
s += "==";
213+
goto case 0;
214+
case 3:
215+
s += "=";
216+
goto case 0;
217+
default:
218+
throw new InvalidOperationException("Illegal base64url string!");
219+
}
220+
}
199221
}
200222
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"n":"3JsFC7E93xAShgnNp9dDWJPOHjJYLGPX464AfKW9gOB5CGD2uIYiP9m6yuZd73Z334RhQw616IMYijAvtpK25Nkk91KoAvrRoUGv2bl6pmX2JwUjwqe+lbmop4Rj9tzC2UBrGPcWSbIMNLaHkUrqR15DwVdFkG19QBwo9X6gOjCgSDvV0OY7vmwq1M3j2YmDwWnyTXh92wnUn2Hg57mVNZCX8RgdhdaWR6tiFP3QtgEYzZEulOGP6PKilqSr7E6Smg7mUNy6JTRkMGm1KZHTAY6HuNG5PPq0DUmsg8YMmsGEQPHMjw7IdaPxO0qy0aC1fiLj8NgWBOJ6bgrck55vfQ==",
3-
"e":"AQAB"
2+
"n": "7jyP7WVsRx9WRj_nvLODxpfWrqtITHtssFc6DC8-FBjwcUAsJE-BOiwbGFoMN6aFgnug3T-EWb4g6UcBrkLlLMNhLLAnE1MvvO5elsaTmIdRNaRKq5W2N1nYZM_Ad17gV5XoXsr82Zl92tHHSbhRTRYIAWUevXA8IOMEw-Q1TeBtIGGAjweclkliNb2T69PitHC4AD1CjuHkrEO7LbmZgfsj-F_RjnD-_6MJ0E9KSiJPJ0RFxzsC72NR2uquDDOBxWluUEgXRFgqd1s_D_t_FehPEgfc5Iy88xOQkD_k3SN8xqeopaZD8OdMwxdGNMjwyD5cw80jlH0lXRLTYK0aiQ",
3+
"e": "AQAB"
44
}

0 commit comments

Comments
 (0)