-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Authorization.cs
106 lines (89 loc) · 3.49 KB
/
Authorization.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Octokit
{
/// <summary>
/// Represents an oauth access given to a particular application.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class Authorization
{
// TODO: I'd love to not need this
public Authorization() { }
public Authorization(long id, string url, Application application, string tokenLastEight, string hashedToken, string fingerprint, string note, string noteUrl, DateTimeOffset createdAt, DateTimeOffset updateAt, string[] scopes)
{
Id = id;
Url = url;
Application = application;
// TODO: testable ctor for new values
//Token = token;
TokenLastEight = tokenLastEight;
HashedToken = hashedToken;
Fingerprint = fingerprint;
Note = note;
NoteUrl = noteUrl;
CreatedAt = createdAt;
UpdateAt = updateAt;
Scopes = scopes;
}
/// <summary>
/// The Id of this <see cref="Authorization"/>.
/// </summary>
public long Id { get; protected set; }
/// <summary>
/// The API URL for this <see cref="Authorization"/>.
/// </summary>
public string Url { get; protected set; }
/// <summary>
/// The <see cref="Application"/> that created this <see cref="Authorization"/>.
/// </summary>
public Application Application { get; protected set; }
/// <summary>
/// The last eight characters of the user's token
/// </summary>
public string TokenLastEight { get; protected set; }
/// <summary>
/// Base-64 encoded representation of the SHA-256 digest of the token
/// </summary>
public string HashedToken { get; protected set; }
/// <summary>
/// Optional parameter that allows an OAuth application to create
/// multiple authorizations for a single user
/// </summary>
public string Fingerprint { get; protected set; }
/// <summary>
/// Notes about this particular <see cref="Authorization"/>.
/// </summary>
public string Note { get; protected set; }
/// <summary>
/// A url for more information about notes.
/// </summary>
public string NoteUrl { get; protected set; }
/// <summary>
/// When this <see cref="Authorization"/> was created.
/// </summary>
public DateTimeOffset CreatedAt { get; protected set; }
/// <summary>
/// When this <see cref="Authorization"/> was last updated.
/// </summary>
public DateTimeOffset UpdateAt { get; protected set; }
/// <summary>
/// The scopes that this <see cref="Authorization"/> has. This is the kind of access that the token allows.
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Special type of model object that only updates none-null fields.")]
public string[] Scopes { get; protected set; }
public string ScopesDelimited
{
get { return string.Join(",", Scopes); }
}
internal string DebuggerDisplay
{
get
{
return string.Format(CultureInfo.InvariantCulture, "Id: {0} CreatedAt: {1} ", Id, CreatedAt);
}
}
}
}