Skip to content

Commit ea8b7af

Browse files
committed
Show complete credentials
1 parent a301f0b commit ea8b7af

2 files changed

Lines changed: 59 additions & 24 deletions

File tree

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
1-
@page "/Credentials"
2-
3-
<h1>Credentials</h1>
4-
5-
<pre>
6-
@{
1+
@page "/Credentials"
2+
3+
<b>Credentials</b>
4+
<br />
5+
6+
<div style="
7+
width:100%;
8+
max-width:100%;
9+
overflow-x:scroll;
10+
box-sizing:border-box;
11+
">
12+
13+
<table style="
14+
width:100%;
15+
table-layout:fixed;
16+
border-collapse:collapse;
17+
">
18+
<tbody>
19+
@foreach (var entry in GetEntries())
20+
{
21+
<tr>
22+
<td style="
23+
border:1px solid #999;
24+
padding:0.5rem;
25+
white-space:pre-wrap;
26+
word-break:break-word;
27+
overflow-wrap:anywhere;
28+
">
29+
@entry
30+
</td>
31+
</tr>
32+
}
33+
</tbody>
34+
</table>
35+
36+
</div>
37+
38+
@code {
39+
IEnumerable<string> GetEntries()
40+
{
741
var text = AasxServer.cs.GetAsText();
8-
text.Replace("\r\n", "<br />");
942

10-
<span>@text</span>
11-
}
12-
</pre>
13-
43+
return text.Split(
44+
"\r\n\r\n",
45+
StringSplitOptions.RemoveEmptyEntries
46+
);
47+
}
48+
}

src/AasxServerStandardBib/Credentials.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public class AasxCredentialsEntry
4545
public string bearer = string.Empty;
4646
public DateTime bearerValidFrom = DateTime.MinValue;
4747
public DateTime bearerValidTo = DateTime.MinValue;
48+
public List<string> bearerList = new List<string>();
4849

4950
public string GetAsText()
5051
{
@@ -58,6 +59,11 @@ public string GetAsText()
5859
text += p + ": " + parameters[p] + "\r\n";
5960
}
6061
text += $"bearer: {bearer}\r\n";
62+
text += "bearerList:\r\n";
63+
for (var b = 0; b < bearerList.Count; b++)
64+
{
65+
text += b + ": " + bearerList[b] + "\r\n";
66+
}
6167
text += "\r\n";
6268

6369
return text;
@@ -296,7 +302,10 @@ public static void bearerCheckAndInit(AasxCredentialsEntry c, AasxTaskService aa
296302
valid = false;
297303
if (valid)
298304
return;
299-
}
305+
}
306+
307+
c.bearer = string.Empty;
308+
c.bearerList.Clear();
300309

301310
string authServerEndPoint = c.parameters[0];
302311

@@ -355,18 +364,6 @@ public static void bearerCheckAndInit(AasxCredentialsEntry c, AasxTaskService aa
355364
Console.WriteLine("clientCertificatePW " + clientCertificatePW);
356365
}
357366

358-
/*
359-
if (c.bearer != string.Empty)
360-
{
361-
bool valid = true;
362-
var jwtToken = new JwtSecurityToken(c.bearer);
363-
if ((jwtToken == null) || (jwtToken.ValidFrom > DateTime.UtcNow) || (jwtToken.ValidTo < DateTime.UtcNow))
364-
valid = false;
365-
if (valid)
366-
return;
367-
}
368-
*/
369-
370367
var handler = new HttpClientHandler()
371368
{
372369
ServerCertificateCustomValidationCallback = delegate { return true; },
@@ -600,6 +597,7 @@ public static void bearerCheckAndInit(AasxCredentialsEntry c, AasxTaskService aa
600597
var response = client.SendAsync(request);
601598
var content = response.GetAwaiter().GetResult().Content.ContentToString();
602599

600+
c.bearerList.Add(c.bearer);
603601
c.bearer = "";
604602
doc = JsonDocument.Parse(content);
605603
if (doc.RootElement.TryGetProperty("access_token", out var tokenElement))
@@ -635,6 +633,7 @@ public static void bearerCheckAndInit(AasxCredentialsEntry c, AasxTaskService aa
635633
var response = client.SendAsync(request);
636634
var content = response.GetAwaiter().GetResult().Content.ContentToString();
637635

636+
c.bearerList.Add(c.bearer);
638637
c.bearer = "";
639638
doc = JsonDocument.Parse(content);
640639
if (doc.RootElement.TryGetProperty("access_token", out var tokenElement))
@@ -670,6 +669,7 @@ public static void bearerCheckAndInit(AasxCredentialsEntry c, AasxTaskService aa
670669
var response = client.SendAsync(request);
671670
var content = response.GetAwaiter().GetResult().Content.ContentToString();
672671

672+
c.bearerList.Add(c.bearer);
673673
c.bearer = "";
674674
doc = JsonDocument.Parse(content);
675675
if (doc.RootElement.TryGetProperty("access_token", out var tokenElement))

0 commit comments

Comments
 (0)