Skip to content

Commit 3ce1b46

Browse files
authored
Merge pull request dotnet-architecture#1548 from borjasanes/feature/identity-api-migration
identity api net 5 migration
2 parents 86e563f + 1fe0121 commit 3ce1b46

21 files changed

Lines changed: 153 additions & 165 deletions

src/Services/Identity/Identity.API/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
1+
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
22
WORKDIR /app
33
EXPOSE 80
44

5-
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
5+
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
66
WORKDIR /src
77

88
# It's important to keep lines from here down to "COPY . ." identical in all Dockerfiles

src/Services/Identity/Identity.API/Identity.API.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<UserSecretsId>aspnet-eShopOnContainers.Identity-90487118-103c-4ff0-b9da-e5e26f7ab0c5</UserSecretsId>
66
<DockerComposeProjectPath>..\..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
77
<GenerateErrorForMissingTargetingPacks>false</GenerateErrorForMissingTargetingPacks>

src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentInputModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
44
{
5-
public class ConsentInputModel
5+
public record ConsentInputModel
66
{
7-
public string Button { get; set; }
8-
public IEnumerable<string> ScopesConsented { get; set; }
9-
public bool RememberConsent { get; set; }
10-
public string ReturnUrl { get; set; }
7+
public string Button { get; init; }
8+
public IEnumerable<string> ScopesConsented { get; init; }
9+
public bool RememberConsent { get; init; }
10+
public string ReturnUrl { get; init; }
1111
}
1212
}

src/Services/Identity/Identity.API/Models/AccountViewModels/ConsentViewModel.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-

2-
3-
using System.Collections.Generic;
1+
using System.Collections.Generic;
42
using System.Linq;
53
using IdentityServer4.Models;
64

75
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
86
{
9-
public class ConsentViewModel : ConsentInputModel
7+
public record ConsentViewModel : ConsentInputModel
108
{
119
public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, Client client, Resources resources)
1210
{
@@ -24,16 +22,16 @@ public ConsentViewModel(ConsentInputModel model, string returnUrl, Authorization
2422
ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray();
2523
}
2624

27-
public string ClientName { get; set; }
28-
public string ClientUrl { get; set; }
29-
public string ClientLogoUrl { get; set; }
30-
public bool AllowRememberConsent { get; set; }
25+
public string ClientName { get; init; }
26+
public string ClientUrl { get; init; }
27+
public string ClientLogoUrl { get; init; }
28+
public bool AllowRememberConsent { get; init; }
3129

32-
public IEnumerable<ScopeViewModel> IdentityScopes { get; set; }
33-
public IEnumerable<ScopeViewModel> ResourceScopes { get; set; }
30+
public IEnumerable<ScopeViewModel> IdentityScopes { get; init; }
31+
public IEnumerable<ScopeViewModel> ResourceScopes { get; init; }
3432
}
3533

36-
public class ScopeViewModel
34+
public record ScopeViewModel
3735
{
3836
public ScopeViewModel(Scope scope, bool check)
3937
{
@@ -55,11 +53,11 @@ public ScopeViewModel(IdentityResource identity, bool check)
5553
Checked = check || identity.Required;
5654
}
5755

58-
public string Name { get; set; }
59-
public string DisplayName { get; set; }
60-
public string Description { get; set; }
61-
public bool Emphasize { get; set; }
62-
public bool Required { get; set; }
63-
public bool Checked { get; set; }
56+
public string Name { get; init; }
57+
public string DisplayName { get; init; }
58+
public string Description { get; init; }
59+
public bool Emphasize { get; init; }
60+
public bool Required { get; init; }
61+
public bool Checked { get; init; }
6462
}
6563
}

src/Services/Identity/Identity.API/Models/AccountViewModels/ForgotPasswordViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
44
{
5-
public class ForgotPasswordViewModel
5+
public record ForgotPasswordViewModel
66
{
77
[Required]
88
[EmailAddress]
9-
public string Email { get; set; }
9+
public string Email { get; init; }
1010
}
1111
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
22
{
3-
public class LoggedOutViewModel
3+
public record LoggedOutViewModel
44
{
5-
public string PostLogoutRedirectUri { get; set; }
6-
public string ClientName { get; set; }
7-
public string SignOutIframeUrl { get; set; }
5+
public string PostLogoutRedirectUri { get; init; }
6+
public string ClientName { get; init; }
7+
public string SignOutIframeUrl { get; init; }
88
}
99
}

src/Services/Identity/Identity.API/Models/AccountViewModels/LoginViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
44
{
5-
public class LoginViewModel
5+
public record LoginViewModel
66
{
77
[Required]
88
[EmailAddress]

src/Services/Identity/Identity.API/Models/AccountViewModels/LogoutViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
22
{
3-
public class LogoutViewModel
3+
public record LogoutViewModel
44
{
55
public string LogoutId { get; set; }
66
}

src/Services/Identity/Identity.API/Models/AccountViewModels/RegisterViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22

33
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
44
{
5-
public class RegisterViewModel
5+
public record RegisterViewModel
66
{
77
[Required]
88
[EmailAddress]
99
[Display(Name = "Email")]
10-
public string Email { get; set; }
10+
public string Email { get; init; }
1111

1212
[Required]
1313
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
1414
[DataType(DataType.Password)]
1515
[Display(Name = "Password")]
16-
public string Password { get; set; }
16+
public string Password { get; init; }
1717

1818
[DataType(DataType.Password)]
1919
[Display(Name = "Confirm password")]
2020
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
21-
public string ConfirmPassword { get; set; }
21+
public string ConfirmPassword { get; init; }
2222

23-
public ApplicationUser User { get; set; }
23+
public ApplicationUser User { get; init; }
2424
}
2525
}

src/Services/Identity/Identity.API/Models/AccountViewModels/ResetPasswordViewModel.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@
22

33
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
44
{
5-
public class ResetPasswordViewModel
5+
public record ResetPasswordViewModel
66
{
77
[Required]
88
[EmailAddress]
9-
public string Email { get; set; }
9+
public string Email { get; init; }
1010

1111
[Required]
1212
[StringLength(100, ErrorMessage = "The {0} must be at least {2} and at max {1} characters long.", MinimumLength = 6)]
1313
[DataType(DataType.Password)]
14-
public string Password { get; set; }
14+
public string Password { get; init; }
1515

1616
[DataType(DataType.Password)]
1717
[Display(Name = "Confirm password")]
1818
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
19-
public string ConfirmPassword { get; set; }
19+
public string ConfirmPassword { get; init; }
2020

21-
public string Code { get; set; }
21+
public string Code { get; init; }
2222
}
2323
}

0 commit comments

Comments
 (0)