Skip to content

Commit 1f4afd8

Browse files
Use models with string IDs.
0 parents  commit 1f4afd8

22 files changed

+5341
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# User-specific files
2+
*.suo
3+
*.user
4+
*.vs
5+
*.log
6+
7+
.awCache
8+
.vscode
9+
.idea
10+
11+
# Build results
12+
bin/
13+
build/
14+
obj/
15+
out/
16+
publish/
17+
uploads/
18+
19+
# Test Output
20+
_test-output/
21+
22+
# NodeJS
23+
node_modules/
24+
25+
docker-build.ps1
26+
appSettings.Development.json
27+
appSettings.Production.json
28+
launchSettings.json
29+

Squidex.OpenIdDict.MongoDb.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.10.35013.160
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Squidex.OpenIdDict.MongoDb", "Squidex.OpenIdDict.MongoDb\Squidex.OpenIdDict.MongoDb.csproj", "{4E00FD17-FCB3-49D8-A08A-3ED345FAA75B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4E00FD17-FCB3-49D8-A08A-3ED345FAA75B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4E00FD17-FCB3-49D8-A08A-3ED345FAA75B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4E00FD17-FCB3-49D8-A08A-3ED345FAA75B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4E00FD17-FCB3-49D8-A08A-3ED345FAA75B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {BBB5F2FB-4ACA-4F5E-B7AA-9EAE74B71CE8}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/openiddict/openiddict-core for more information concerning
4+
* the license and the contributors participating to this project.
5+
*/
6+
7+
using System.ComponentModel;
8+
9+
namespace OpenIddict.MongoDb;
10+
11+
/// <summary>
12+
/// Exposes the MongoDB database used by the OpenIddict stores.
13+
/// </summary>
14+
[EditorBrowsable(EditorBrowsableState.Advanced)]
15+
public interface IOpenIddictMongoDbContext
16+
{
17+
/// <summary>
18+
/// Gets the <see cref="IMongoDatabase"/>.
19+
/// </summary>
20+
/// <returns>
21+
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the
22+
/// asynchronous operation, whose result returns the MongoDB database.
23+
/// </returns>
24+
ValueTask<IMongoDatabase> GetDatabaseAsync(CancellationToken cancellationToken);
25+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/openiddict/openiddict-core for more information concerning
4+
* the license and the contributors participating to this project.
5+
*/
6+
7+
using System.Collections.Immutable;
8+
using System.Diagnostics;
9+
10+
namespace OpenIddict.MongoDb.Models;
11+
12+
/// <summary>
13+
/// Represents an OpenIddict application.
14+
/// </summary>
15+
[DebuggerDisplay("Id = {Id.ToString(),nq} ; ClientId = {ClientId,nq} ; ClientType = {ClientType,nq}")]
16+
public class OpenIddictMongoDbApplication
17+
{
18+
/// <summary>
19+
/// Gets or sets the application type associated with the current application.
20+
/// </summary>
21+
[BsonElement("application_type"), BsonIgnoreIfNull]
22+
public virtual string? ApplicationType { get; set; }
23+
24+
/// <summary>
25+
/// Gets or sets the client identifier associated with the current application.
26+
/// </summary>
27+
[BsonElement("client_id"), BsonIgnoreIfNull]
28+
public virtual string? ClientId { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the client secret associated with the current application.
32+
/// Note: depending on the application manager used to create this instance,
33+
/// this property may be hashed or encrypted for security reasons.
34+
/// </summary>
35+
[BsonElement("client_secret"), BsonIgnoreIfNull]
36+
public virtual string? ClientSecret { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the client type associated with the current application.
40+
/// </summary>
41+
[BsonElement("client_type"), BsonIgnoreIfNull]
42+
public virtual string? ClientType { get; set; }
43+
44+
/// <summary>
45+
/// Gets or sets the concurrency token.
46+
/// </summary>
47+
[BsonElement("concurrency_token"), BsonIgnoreIfNull]
48+
public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
49+
50+
/// <summary>
51+
/// Gets or sets the consent type associated with the current application.
52+
/// </summary>
53+
[BsonElement("consent_type"), BsonIgnoreIfNull]
54+
public virtual string? ConsentType { get; set; }
55+
56+
/// <summary>
57+
/// Gets or sets the display name associated with the current application.
58+
/// </summary>
59+
[BsonElement("display_name"), BsonIgnoreIfNull]
60+
public virtual string? DisplayName { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets the localized display names associated with the current application.
64+
/// </summary>
65+
[BsonElement("display_names"), BsonIgnoreIfNull]
66+
public virtual IReadOnlyDictionary<string, string>? DisplayNames { get; set; }
67+
= ImmutableDictionary.Create<string, string>();
68+
69+
/// <summary>
70+
/// Gets or sets the unique identifier associated with the current application.
71+
/// </summary>
72+
[BsonId, BsonRequired]
73+
public virtual string Id { get; set; } = null!;
74+
75+
/// <summary>
76+
/// Gets or sets the JSON Web Key Set associated with the application.
77+
/// </summary>
78+
[BsonElement("json_web_key_set"), BsonIgnoreIfNull]
79+
public virtual BsonDocument? JsonWebKeySet { get; set; }
80+
81+
/// <summary>
82+
/// Gets or sets the permissions associated with the current application.
83+
/// </summary>
84+
[BsonElement("permissions"), BsonIgnoreIfNull]
85+
public virtual IReadOnlyList<string>? Permissions { get; set; } = ImmutableList.Create<string>();
86+
87+
/// <summary>
88+
/// Gets or sets the post-logout redirect URIs associated with the current application.
89+
/// </summary>
90+
[BsonElement("post_logout_redirect_uris"), BsonIgnoreIfNull]
91+
public virtual IReadOnlyList<string>? PostLogoutRedirectUris { get; set; } = ImmutableList.Create<string>();
92+
93+
/// <summary>
94+
/// Gets or sets the additional properties associated with the current application.
95+
/// </summary>
96+
[BsonElement("properties"), BsonIgnoreIfNull]
97+
public virtual BsonDocument? Properties { get; set; }
98+
99+
/// <summary>
100+
/// Gets or sets the redirect URIs associated with the current application.
101+
/// </summary>
102+
[BsonElement("redirect_uris"), BsonIgnoreIfNull]
103+
public virtual IReadOnlyList<string>? RedirectUris { get; set; } = ImmutableList.Create<string>();
104+
105+
/// <summary>
106+
/// Gets or sets the requirements associated with the current application.
107+
/// </summary>
108+
[BsonElement("requirements"), BsonIgnoreIfNull]
109+
public virtual IReadOnlyList<string>? Requirements { get; set; } = ImmutableList.Create<string>();
110+
111+
/// <summary>
112+
/// Gets or sets the settings associated with the current application.
113+
/// </summary>
114+
[BsonElement("settings"), BsonIgnoreIfNull]
115+
public virtual IReadOnlyDictionary<string, string>? Settings { get; set; }
116+
= ImmutableDictionary.Create<string, string>();
117+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/openiddict/openiddict-core for more information concerning
4+
* the license and the contributors participating to this project.
5+
*/
6+
7+
using System.Collections.Immutable;
8+
using System.Diagnostics;
9+
10+
namespace OpenIddict.MongoDb.Models;
11+
12+
/// <summary>
13+
/// Represents an OpenIddict authorization.
14+
/// </summary>
15+
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Subject = {Subject,nq} ; Type = {Type,nq} ; Status = {Status,nq}")]
16+
public class OpenIddictMongoDbAuthorization
17+
{
18+
/// <summary>
19+
/// Gets or sets the identifier of the application associated with the current authorization.
20+
/// </summary>
21+
[BsonElement("application_id"), BsonIgnoreIfDefault]
22+
public virtual string ApplicationId { get; set; } = null!;
23+
24+
/// <summary>
25+
/// Gets or sets the concurrency token.
26+
/// </summary>
27+
[BsonElement("concurrency_token"), BsonIgnoreIfNull]
28+
public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
29+
30+
/// <summary>
31+
/// Gets or sets the UTC creation date of the current authorization.
32+
/// </summary>
33+
[BsonElement("creation_date"), BsonIgnoreIfNull]
34+
public virtual DateTime? CreationDate { get; set; }
35+
36+
/// <summary>
37+
/// Gets or sets the unique identifier associated with the current authorization.
38+
/// </summary>
39+
[BsonId, BsonRequired]
40+
public virtual string Id { get; set; } = null!;
41+
42+
/// <summary>
43+
/// Gets or sets the additional properties associated with the current authorization.
44+
/// </summary>
45+
[BsonElement("properties"), BsonIgnoreIfNull]
46+
public virtual BsonDocument? Properties { get; set; }
47+
48+
/// <summary>
49+
/// Gets or sets the scopes associated with the current authorization.
50+
/// </summary>
51+
[BsonElement("scopes"), BsonIgnoreIfNull]
52+
public virtual IReadOnlyList<string>? Scopes { get; set; } = ImmutableList.Create<string>();
53+
54+
/// <summary>
55+
/// Gets or sets the status of the current authorization.
56+
/// </summary>
57+
[BsonElement("status"), BsonIgnoreIfNull]
58+
public virtual string? Status { get; set; }
59+
60+
/// <summary>
61+
/// Gets or sets the subject associated with the current authorization.
62+
/// </summary>
63+
[BsonElement("subject"), BsonIgnoreIfNull]
64+
public virtual string? Subject { get; set; }
65+
66+
/// <summary>
67+
/// Gets or sets the type of the current authorization.
68+
/// </summary>
69+
[BsonElement("type"), BsonIgnoreIfNull]
70+
public virtual string? Type { get; set; }
71+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
3+
* See https://github.com/openiddict/openiddict-core for more information concerning
4+
* the license and the contributors participating to this project.
5+
*/
6+
7+
using System.Collections.Immutable;
8+
using System.Diagnostics;
9+
10+
namespace OpenIddict.MongoDb.Models;
11+
12+
/// <summary>
13+
/// Represents an OpenIddict scope.
14+
/// </summary>
15+
[DebuggerDisplay("Id = {Id.ToString(),nq} ; Name = {Name,nq}")]
16+
public class OpenIddictMongoDbScope
17+
{
18+
/// <summary>
19+
/// Gets or sets the concurrency token.
20+
/// </summary>
21+
[BsonElement("concurrency_token"), BsonIgnoreIfNull]
22+
public virtual string? ConcurrencyToken { get; set; } = Guid.NewGuid().ToString();
23+
24+
/// <summary>
25+
/// Gets or sets the public description associated with the current scope.
26+
/// </summary>
27+
[BsonElement("description"), BsonIgnoreIfNull]
28+
public virtual string? Description { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the localized public descriptions associated with the current scope.
32+
/// </summary>
33+
[BsonElement("descriptions"), BsonIgnoreIfNull]
34+
public virtual IReadOnlyDictionary<string, string>? Descriptions { get; set; }
35+
= ImmutableDictionary.Create<string, string>();
36+
37+
/// <summary>
38+
/// Gets or sets the display name associated with the current scope.
39+
/// </summary>
40+
[BsonElement("display_name"), BsonIgnoreIfNull]
41+
public virtual string? DisplayName { get; set; }
42+
43+
/// <summary>
44+
/// Gets or sets the localized display names associated with the current scope.
45+
/// </summary>
46+
[BsonElement("display_names"), BsonIgnoreIfNull]
47+
public virtual IReadOnlyDictionary<string, string>? DisplayNames { get; set; }
48+
= ImmutableDictionary.Create<string, string>();
49+
50+
/// <summary>
51+
/// Gets or sets the unique identifier associated with the current scope.
52+
/// </summary>
53+
[BsonId, BsonRequired]
54+
public virtual string Id { get; set; } = null!;
55+
56+
/// <summary>
57+
/// Gets or sets the unique name associated with the current scope.
58+
/// </summary>
59+
[BsonElement("name"), BsonIgnoreIfNull]
60+
public virtual string? Name { get; set; }
61+
62+
/// <summary>
63+
/// Gets or sets the additional properties associated with the current scope.
64+
/// </summary>
65+
[BsonElement("properties"), BsonIgnoreIfNull]
66+
public virtual BsonDocument? Properties { get; set; }
67+
68+
/// <summary>
69+
/// Gets or sets the resources associated with the current scope.
70+
/// </summary>
71+
[BsonElement("resources"), BsonIgnoreIfNull]
72+
public virtual IReadOnlyList<string>? Resources { get; set; } = ImmutableList.Create<string>();
73+
}

0 commit comments

Comments
 (0)