forked from gitter-badger/IdentityServer4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdentityResource.cs
More file actions
71 lines (61 loc) · 2.72 KB
/
IdentityResource.cs
File metadata and controls
71 lines (61 loc) · 2.72 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
// 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 a user identity resource.
/// </summary>
public class IdentityResource : Resource
{
/// <summary>
/// Initializes a new instance of the <see cref="IdentityResource"/> class.
/// </summary>
public IdentityResource()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="IdentityResource"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="claimTypes">The claim types.</param>
public IdentityResource(string name, IEnumerable<string> claimTypes)
: this(name, name, claimTypes)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="IdentityResource"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="displayName">The display name.</param>
/// <param name="claimTypes">The claim types.</param>
/// <exception cref="System.ArgumentNullException">name</exception>
/// <exception cref="System.ArgumentException">Must provide at least one claim type - claimTypes</exception>
public IdentityResource(string name, string displayName, IEnumerable<string> claimTypes)
{
if (name.IsMissing()) throw new ArgumentNullException(nameof(name));
if (claimTypes.IsNullOrEmpty()) throw new ArgumentException("Must provide at least one claim type", nameof(claimTypes));
Name = name;
DisplayName = displayName;
foreach(var type in claimTypes)
{
UserClaims.Add(type);
}
}
/// <summary>
/// Specifies whether the user can de-select the scope on the consent screen (if the consent screen wants to implement such a feature). Defaults to false.
/// </summary>
public bool Required { get; set; } = false;
/// <summary>
/// Specifies whether the consent screen will emphasize this scope (if the consent screen wants to implement such a feature).
/// 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;
}
}