This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
/
FormsAuthenticationConfiguration.cs
85 lines (72 loc) · 2.7 KB
/
FormsAuthenticationConfiguration.cs
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
82
83
84
85
namespace Nancy.Authentication.Forms
{
using Cryptography;
/// <summary>
/// Configuration options for forms authentication
/// </summary>
public class FormsAuthenticationConfiguration
{
internal const string DefaultRedirectQuerystringKey = "returnUrl";
/// <summary>
/// Initializes a new instance of the <see cref="FormsAuthenticationConfiguration"/> class.
/// </summary>
public FormsAuthenticationConfiguration() : this(CryptographyConfiguration.Default)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="FormsAuthenticationConfiguration"/> class.
/// </summary>
/// <param name="cryptographyConfiguration">Cryptography configuration</param>
public FormsAuthenticationConfiguration(CryptographyConfiguration cryptographyConfiguration)
{
CryptographyConfiguration = cryptographyConfiguration;
RedirectQuerystringKey = DefaultRedirectQuerystringKey;
}
/// <summary>
/// Gets or sets the forms authentication query string key for storing the return url
/// </summary>
public string RedirectQuerystringKey { get; set; }
/// <summary>
/// Gets or sets the redirect url for pages that require authentication
/// </summary>
public string RedirectUrl { get; set; }
/// <summary>
/// Gets or sets the username/identifier mapper
/// </summary>
public IUserMapper UserMapper { get; set; }
/// <summary>
/// Gets or sets the cryptography configuration
/// </summary>
public CryptographyConfiguration CryptographyConfiguration { get; set; }
/// <summary>
/// Gets a value indicating whether the configuration is valid or not.
/// </summary>
public virtual bool IsValid
{
get
{
if (string.IsNullOrEmpty(this.RedirectUrl))
{
return false;
}
if (this.UserMapper == null)
{
return false;
}
if (this.CryptographyConfiguration == null)
{
return false;
}
if (this.CryptographyConfiguration.EncryptionProvider == null)
{
return false;
}
if (this.CryptographyConfiguration.HmacProvider == null)
{
return false;
}
return true;
}
}
}
}