-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 933198c.
- Loading branch information
Showing
563 changed files
with
45,636 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
LICENSE | ||
README.md | ||
!**/.gitignore | ||
!.git/HEAD | ||
!.git/config | ||
!.git/packed-refs | ||
!.git/refs/heads/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Logitar.Cms.Contracts.Sessions; | ||
using Logitar.Cms.Contracts.Users; | ||
|
||
namespace Logitar.Cms.Contracts.Account; | ||
|
||
public record CurrentUser | ||
{ | ||
public string DisplayName { get; set; } | ||
public string? EmailAddress { get; set; } | ||
public string? PictureUrl { get; set; } | ||
|
||
public CurrentUser() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public CurrentUser(Session session) : this(session.User) | ||
{ | ||
} | ||
|
||
public CurrentUser(User user) : this(user.FullName ?? user.UniqueName) | ||
{ | ||
EmailAddress = user.Email?.Address; | ||
PictureUrl = user.Picture; | ||
} | ||
|
||
public CurrentUser(string displayName) | ||
{ | ||
DisplayName = displayName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Logitar.Cms.Contracts.Account; | ||
|
||
public record GetTokenPayload | ||
{ | ||
[JsonPropertyName("refresh_token")] | ||
public string? RefreshToken { get; set; } | ||
|
||
public SignInPayload? Credentials { get; set; } | ||
} |
17 changes: 17 additions & 0 deletions
17
backend/src/Logitar.Cms.Contracts/Account/SignInPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Logitar.Cms.Contracts.Account; | ||
|
||
public record SignInPayload | ||
{ | ||
public string Username { get; set; } | ||
public string Password { get; set; } | ||
|
||
public SignInPayload() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
|
||
public SignInPayload(string username, string password) | ||
{ | ||
Username = username; | ||
Password = password; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
backend/src/Logitar.Cms.Contracts/Account/TokenResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
namespace Logitar.Cms.Contracts.Account; | ||
|
||
public record TokenResponse | ||
{ | ||
[JsonPropertyName("access_token")] | ||
public string AccessToken { get; set; } | ||
|
||
[JsonPropertyName("token_type")] | ||
public string TokenType { get; set; } | ||
|
||
[JsonPropertyName("expires_in")] | ||
public int? ExpiresIn { get; set; } | ||
|
||
[JsonPropertyName("refresh_token")] | ||
public string? RefreshToken { get; set; } | ||
|
||
[JsonPropertyName("scope")] | ||
public string? Scope { get; set; } | ||
|
||
public TokenResponse() : this(string.Empty, string.Empty) | ||
{ | ||
} | ||
|
||
public TokenResponse(string accessToken, string tokenType) | ||
{ | ||
AccessToken = accessToken; | ||
TokenType = tokenType; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Logitar.Cms.Contracts.Users; | ||
|
||
namespace Logitar.Cms.Contracts.Account; | ||
|
||
public record UserProfile | ||
{ | ||
public string Username { get; set; } | ||
|
||
public DateTime? PasswordChangedOn { get; set; } | ||
|
||
public string? EmailAddress { get; set; } | ||
|
||
public string? FirstName { get; set; } | ||
public string? MiddleName { get; set; } | ||
public string? LastName { get; set; } | ||
public string? FullName { get; set; } | ||
|
||
public Locale? Locale { get; set; } | ||
|
||
public string? Picture { get; set; } | ||
|
||
public DateTime CreatedOn { get; set; } | ||
public DateTime UpdatedOn { get; set; } | ||
public DateTime AuthenticatedOn { get; set; } | ||
|
||
public UserProfile() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public UserProfile(string username) | ||
{ | ||
Username = username; | ||
} | ||
|
||
public UserProfile(User user) : this(user.UniqueName) | ||
{ | ||
PasswordChangedOn = user.PasswordChangedOn; | ||
|
||
EmailAddress = user.Email?.Address; | ||
|
||
FirstName = user.FirstName; | ||
MiddleName = user.MiddleName; | ||
LastName = user.LastName; | ||
FullName = user.FullName; | ||
|
||
Locale = user.Locale; | ||
|
||
Picture = user.Picture; | ||
|
||
CreatedOn = user.CreatedOn; | ||
UpdatedOn = user.UpdatedOn; | ||
AuthenticatedOn = user.AuthenticatedOn ?? user.UpdatedOn; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Logitar.Cms.Contracts.ApiKeys; | ||
using Logitar.Cms.Contracts.Users; | ||
|
||
namespace Logitar.Cms.Contracts.Actors; | ||
|
||
public class Actor | ||
{ | ||
public static Actor System => new(ActorType.System.ToString()); | ||
|
||
public Guid Id { get; set; } | ||
public ActorType Type { get; set; } | ||
public bool IsDeleted { get; set; } | ||
|
||
public string DisplayName { get; set; } | ||
public string? EmailAddress { get; set; } | ||
public string? PictureUrl { get; set; } | ||
|
||
public Actor() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public Actor(ApiKey apiKey) : this(apiKey.DisplayName) | ||
{ | ||
Id = apiKey.Id; | ||
Type = ActorType.ApiKey; | ||
} | ||
|
||
public Actor(User user) : this(user.FullName ?? user.UniqueName) | ||
{ | ||
Id = user.Id; | ||
Type = ActorType.User; | ||
|
||
EmailAddress = user.Email?.Address; | ||
PictureUrl = user.Picture; | ||
} | ||
|
||
public Actor(string displayName) | ||
{ | ||
DisplayName = displayName; | ||
} | ||
|
||
public override bool Equals(object obj) => obj is Actor actor && actor.Id == Id; | ||
public override int GetHashCode() => Id.GetHashCode(); | ||
public override string ToString() | ||
{ | ||
StringBuilder s = new(); | ||
|
||
s.Append(DisplayName); | ||
if (EmailAddress != null) | ||
{ | ||
s.Append(" <").Append(EmailAddress).Append('>'); | ||
} | ||
s.Append(" (").Append(Type).Append(".Id=").Append(Id).Append(')'); | ||
|
||
return s.ToString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Logitar.Cms.Contracts.Actors; | ||
|
||
public enum ActorType | ||
{ | ||
System = 0, | ||
User = 1, | ||
ApiKey = 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Logitar.Cms.Contracts.Actors; | ||
|
||
namespace Logitar.Cms.Contracts; | ||
|
||
public abstract class Aggregate | ||
{ | ||
public Guid Id { get; set; } | ||
public long Version { get; set; } | ||
|
||
public Actor CreatedBy { get; set; } = new(); | ||
public DateTime CreatedOn { get; set; } | ||
|
||
public Actor UpdatedBy { get; set; } = new(); | ||
public DateTime UpdatedOn { get; set; } | ||
|
||
public override bool Equals(object obj) => obj is Aggregate aggregate && aggregate.GetType().Equals(GetType()) && aggregate.Id == Id; | ||
public override int GetHashCode() => HashCode.Combine(GetType(), Id); | ||
public override string ToString() => $"{GetType()} (Id={Id})"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Logitar.Cms.Contracts.Roles; | ||
|
||
namespace Logitar.Cms.Contracts.ApiKeys; | ||
|
||
public class ApiKey : Aggregate | ||
{ | ||
public string? XApiKey { get; set; } | ||
|
||
public string DisplayName { get; set; } | ||
public string? Description { get; set; } | ||
public DateTime? ExpiresOn { get; set; } | ||
|
||
public DateTime? AuthenticatedOn { get; set; } | ||
|
||
public List<CustomAttribute> CustomAttributes { get; set; } | ||
|
||
public List<Role> Roles { get; set; } | ||
|
||
public ApiKey() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public ApiKey(string displayName) | ||
{ | ||
DisplayName = displayName; | ||
CustomAttributes = []; | ||
Roles = []; | ||
} | ||
|
||
public override string ToString() => $"{DisplayName} | {base.ToString()}"; | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/Logitar.Cms.Contracts/ApiKeys/AuthenticateApiKeyPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Logitar.Cms.Contracts.ApiKeys; | ||
|
||
public record AuthenticateApiKeyPayload | ||
{ | ||
public string XApiKey { get; set; } | ||
|
||
public AuthenticateApiKeyPayload() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public AuthenticateApiKeyPayload(string xApiKey) | ||
{ | ||
XApiKey = xApiKey; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/src/Logitar.Cms.Contracts/ApiKeys/CreateApiKeyPayload.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Logitar.Cms.Contracts.ApiKeys; | ||
|
||
public record CreateApiKeyPayload // ISSUE: https://github.com/Logitar/CMS/issues/11 | ||
{ | ||
public string DisplayName { get; set; } | ||
public string? Description { get; set; } | ||
public DateTime? ExpiresOn { get; set; } | ||
|
||
public List<CustomAttribute> CustomAttributes { get; set; } | ||
|
||
public CreateApiKeyPayload() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public CreateApiKeyPayload(string displayName) | ||
{ | ||
DisplayName = displayName; | ||
|
||
CustomAttributes = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Logitar.Cms.Contracts; | ||
|
||
public record Change<T> | ||
{ | ||
public T? Value { get; } | ||
|
||
public Change(T? value = default) | ||
{ | ||
Value = value; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/Logitar.Cms.Contracts/Configurations/Configuration.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public class Configuration : Aggregate | ||
{ | ||
public string Secret { get; set; } | ||
|
||
public UniqueNameSettings UniqueNameSettings { get; set; } | ||
public PasswordSettings PasswordSettings { get; set; } | ||
public bool RequireUniqueEmail { get; set; } | ||
|
||
public LoggingSettings LoggingSettings { get; set; } | ||
|
||
public Configuration() : this(string.Empty) | ||
{ | ||
} | ||
|
||
public Configuration(string secret) | ||
{ | ||
Secret = secret; | ||
|
||
UniqueNameSettings = new(); | ||
PasswordSettings = new(); | ||
|
||
LoggingSettings = new(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/Logitar.Cms.Contracts/Configurations/ILoggingSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public interface ILoggingSettings | ||
{ | ||
LoggingExtent Extent { get; } | ||
bool OnlyErrors { get; } | ||
} |
8 changes: 8 additions & 0 deletions
8
backend/src/Logitar.Cms.Contracts/Configurations/LoggingExtent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Logitar.Cms.Contracts.Configurations; | ||
|
||
public enum LoggingExtent | ||
{ | ||
None = 0, | ||
ActivityOnly = 1, | ||
Full = 2 | ||
} |
Oops, something went wrong.