forked from gitter-badger/IdentityServer4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScope.cs
More file actions
110 lines (94 loc) · 3.69 KB
/
Scope.cs
File metadata and controls
110 lines (94 loc) · 3.69 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
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
107
108
109
110
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using IdentityServer4.Extensions;
using System;
using System.Collections.Generic;
namespace IdentityServer4.Models
{
/// <summary>
/// Models access to an API resource
/// </summary>
public class Scope
{
/// <summary>
/// Initializes a new instance of the <see cref="Scope"/> class.
/// </summary>
public Scope()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scope"/> class.
/// </summary>
/// <param name="name">The name.</param>
public Scope(string name)
: this(name, name, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scope"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="displayName">The display name.</param>
public Scope(string name, string displayName)
: this(name, displayName, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scope"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="claimTypes">The user-claim types.</param>
public Scope(string name, IEnumerable<string> claimTypes)
: this(name, name, claimTypes)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scope"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="displayName">The display name.</param>
/// <param name="claimTypes">The user-claim types.</param>
/// <exception cref="System.ArgumentNullException">name</exception>
public Scope(string name, string displayName, IEnumerable<string> claimTypes)
{
if (name.IsMissing()) throw new ArgumentNullException(nameof(name));
Name = name;
DisplayName = displayName;
if (!claimTypes.IsNullOrEmpty())
{
foreach (var type in claimTypes)
{
UserClaims.Add(type);
}
}
}
/// <summary>
/// Name of the scope. This is the value a client will use to request the scope.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Display name. This value will be used e.g. on the consent screen.
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// Description. This value will be used e.g. on the consent screen.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Specifies whether the user can de-select the scope on the consent screen. Defaults to false.
/// </summary>
public bool Required { get; set; } = false;
/// <summary>
/// Specifies whether the consent screen will emphasize this scope. Use this setting for sensitive or important scopes. Defaults to false.
/// </summary>
public bool Emphasize { get; set; } = false;
/// <summary>
/// Specifies whether this scope is shown in the discovery document. Defaults to true.
/// </summary>
public bool ShowInDiscoveryDocument { get; set; } = true;
/// <summary>
/// List of user-claim types that should be included in the access token.
/// </summary>
public ICollection<string> UserClaims { get; set; } = new HashSet<string>();
}
}