-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathHttpAuthenticationScheme.cs
More file actions
81 lines (76 loc) · 2.35 KB
/
HttpAuthenticationScheme.cs
File metadata and controls
81 lines (76 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System.Threading.Tasks;
using Waher.Security;
namespace Waher.Networking.HTTP
{
/// <summary>
/// Base class for all HTTP authentication schemes, as defined in RFC-7235:
/// https://datatracker.ietf.org/doc/rfc7235/
/// </summary>
public abstract class HttpAuthenticationScheme
{
private readonly bool requireEncryption;
#if !WINDOWS_UWP
private readonly int minStrength;
#endif
/// <summary>
/// Base class for all HTTP authentication schemes, as defined in RFC-7235:
/// https://datatracker.ietf.org/doc/rfc7235/
/// </summary>
public HttpAuthenticationScheme()
#if WINDOWS_UWP
: this(false)
#else
: this(false, 0)
#endif
{
}
#if WINDOWS_UWP
/// <summary>
/// Base class for all HTTP authentication schemes, as defined in RFC-7235:
/// https://datatracker.ietf.org/doc/rfc7235/
/// </summary>
/// <param name="RequireEncryption">If encryption is required.</param>
public HttpAuthenticationScheme(bool RequireEncryption)
{
this.requireEncryption = RequireEncryption;
}
#else
/// <summary>
/// Base class for all HTTP authentication schemes, as defined in RFC-7235:
/// https://datatracker.ietf.org/doc/rfc7235/
/// </summary>
/// <param name="RequireEncryption">If encryption is required.</param>
/// <param name="MinStrength">Minimum security strength of algorithms used.</param>
public HttpAuthenticationScheme(bool RequireEncryption, int MinStrength)
{
this.requireEncryption = RequireEncryption;
this.minStrength = MinStrength;
}
#endif
/// <summary>
/// If scheme requires encryption.
/// </summary>
public bool RequireEncryption => this.requireEncryption;
#if !WINDOWS_UWP
/// <summary>
/// Minimum security strength of algorithms used.
/// </summary>
public int MinStrength => this.minStrength;
#endif
/// <summary>
/// If the authentication scheme uses user sessions.
/// </summary>
public virtual bool UserSessions => false;
/// <summary>
/// Gets a challenge for the authenticating client to respond to.
/// </summary>
/// <returns>Challenge string.</returns>
public abstract string GetChallenge();
/// <summary>
/// Checks if the request is authorized.
/// </summary>
/// <param name="Request">Request object.</param>
/// <returns>User object, if authenticated, or null otherwise.</returns>
public abstract Task<IUser> IsAuthenticated(HttpRequest Request);
}
}