Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
327 changes: 163 additions & 164 deletions src/Identity.API/Configuration/Config.cs
Original file line number Diff line number Diff line change
@@ -1,192 +1,191 @@
namespace eShop.Identity.API.Configuration
namespace eShop.Identity.API.Configuration;

public class Config
{
public class Config
// ApiResources define the apis in your system
public static IEnumerable<ApiResource> GetApis()
{
// ApiResources define the apis in your system
public static IEnumerable<ApiResource> GetApis()
return new List<ApiResource>
{
return new List<ApiResource>
{
new ApiResource("orders", "Orders Service"),
new ApiResource("basket", "Basket Service"),
new ApiResource("webhooks", "Webhooks registration Service"),
};
}
new ApiResource("orders", "Orders Service"),
new ApiResource("basket", "Basket Service"),
new ApiResource("webhooks", "Webhooks registration Service"),
};
}

// ApiScope is used to protect the API
//The effect is the same as that of API resources in IdentityServer 3.x
public static IEnumerable<ApiScope> GetApiScopes()
// ApiScope is used to protect the API
//The effect is the same as that of API resources in IdentityServer 3.x
public static IEnumerable<ApiScope> GetApiScopes()
{
return new List<ApiScope>
{
return new List<ApiScope>
{
new ApiScope("orders", "Orders Service"),
new ApiScope("basket", "Basket Service"),
new ApiScope("webhooks", "Webhooks registration Service"),
};
}
new ApiScope("orders", "Orders Service"),
new ApiScope("basket", "Basket Service"),
new ApiScope("webhooks", "Webhooks registration Service"),
};
}

// Identity resources are data like user ID, name, or email address of a user
// see: http://docs.identityserver.io/en/release/configuration/resources.html
public static IEnumerable<IdentityResource> GetResources()
// Identity resources are data like user ID, name, or email address of a user
// see: http://docs.identityserver.io/en/release/configuration/resources.html
public static IEnumerable<IdentityResource> GetResources()
{
return new List<IdentityResource>
{
return new List<IdentityResource>
{
new IdentityResources.OpenId(),
new IdentityResources.Profile()
};
}
new IdentityResources.OpenId(),
new IdentityResources.Profile()
};
}

// client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients(IConfiguration configuration)
// client want to access resources (aka scopes)
public static IEnumerable<Client> GetClients(IConfiguration configuration)
{
return new List<Client>
{
return new List<Client>
new Client
{
ClientId = "maui",
ClientName = "eShop MAUI OpenId Client",
AllowedGrantTypes = GrantTypes.Code,
//Used to retrieve the access token on the back channel.
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { configuration["MauiCallback"] },
RequireConsent = false,
RequirePkce = true,
PostLogoutRedirectUris = { $"{configuration["MauiCallback"]}/Account/Redirecting" },
//AllowedCorsOrigins = { "http://eshopxamarin" },
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"mobileshoppingagg",
"webhooks"
},
//Allow requesting refresh tokens for long lived API access
AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true,
AlwaysIncludeUserClaimsInIdToken = true,
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
},
new Client
{
new Client
ClientId = "webapp",
ClientName = "WebApp Client",
ClientSecrets = new List<Secret>
{
ClientId = "maui",
ClientName = "eShop MAUI OpenId Client",
AllowedGrantTypes = GrantTypes.Code,
//Used to retrieve the access token on the back channel.
ClientSecrets =
{
new Secret("secret".Sha256())
},
RedirectUris = { configuration["MauiCallback"] },
RequireConsent = false,
RequirePkce = true,
PostLogoutRedirectUris = { $"{configuration["MauiCallback"]}/Account/Redirecting" },
//AllowedCorsOrigins = { "http://eshopxamarin" },
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"mobileshoppingagg",
"webhooks"
},
//Allow requesting refresh tokens for long lived API access
AllowOfflineAccess = true,
AllowAccessTokensViaBrowser = true,
AlwaysIncludeUserClaimsInIdToken = true,
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
new Secret("secret".Sha256())
},
new Client
ClientUri = $"{configuration["WebAppClient"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Code,
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RequirePkce = false,
RedirectUris = new List<string>
{
ClientId = "webapp",
ClientName = "WebApp Client",
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
ClientUri = $"{configuration["WebAppClient"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Code,
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RequirePkce = false,
RedirectUris = new List<string>
{
$"{configuration["WebAppClient"]}/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
$"{configuration["WebAppClient"]}/signout-callback-oidc"
},
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"webshoppingagg",
"webhooks"
},
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
$"{configuration["WebAppClient"]}/signin-oidc"
},
new Client
PostLogoutRedirectUris = new List<string>
{
ClientId = "webhooksclient",
ClientName = "Webhooks Client",
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
ClientUri = $"{configuration["WebhooksWebClient"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Code,
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RedirectUris = new List<string>
{
$"{configuration["WebhooksWebClient"]}/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
$"{configuration["WebhooksWebClient"]}/signout-callback-oidc"
},
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"webhooks"
},
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
$"{configuration["WebAppClient"]}/signout-callback-oidc"
},
new Client
AllowedScopes = new List<string>
{
ClientId = "basketswaggerui",
ClientName = "Basket Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"orders",
"basket",
"webshoppingagg",
"webhooks"
},
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
},
new Client
{
ClientId = "webhooksclient",
ClientName = "Webhooks Client",
ClientSecrets = new List<Secret>
{
new Secret("secret".Sha256())
},
ClientUri = $"{configuration["WebhooksWebClient"]}", // public uri of the client
AllowedGrantTypes = GrantTypes.Code,
AllowAccessTokensViaBrowser = false,
RequireConsent = false,
AllowOfflineAccess = true,
AlwaysIncludeUserClaimsInIdToken = true,
RedirectUris = new List<string>
{
$"{configuration["WebhooksWebClient"]}/signin-oidc"
},
PostLogoutRedirectUris = new List<string>
{
$"{configuration["WebhooksWebClient"]}/signout-callback-oidc"
},
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.OfflineAccess,
"webhooks"
},
AccessTokenLifetime = 60*60*2, // 2 hours
IdentityTokenLifetime= 60*60*2 // 2 hours
},
new Client
{
ClientId = "basketswaggerui",
ClientName = "Basket Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,

RedirectUris = { $"{configuration["BasketApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["BasketApiClient"]}/swagger/" },
RedirectUris = { $"{configuration["BasketApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["BasketApiClient"]}/swagger/" },

AllowedScopes =
{
"basket"
}
},
new Client
AllowedScopes =
{
ClientId = "orderingswaggerui",
ClientName = "Ordering Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
"basket"
}
},
new Client
{
ClientId = "orderingswaggerui",
ClientName = "Ordering Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,

RedirectUris = { $"{configuration["OrderingApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["OrderingApiClient"]}/swagger/" },
RedirectUris = { $"{configuration["OrderingApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["OrderingApiClient"]}/swagger/" },

AllowedScopes =
{
"orders"
}
},
new Client
AllowedScopes =
{
ClientId = "webhooksswaggerui",
ClientName = "WebHooks Service Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,
"orders"
}
},
new Client
{
ClientId = "webhooksswaggerui",
ClientName = "WebHooks Service Swagger UI",
AllowedGrantTypes = GrantTypes.Implicit,
AllowAccessTokensViaBrowser = true,

RedirectUris = { $"{configuration["WebhooksApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["WebhooksApiClient"]}/swagger/" },
RedirectUris = { $"{configuration["WebhooksApiClient"]}/swagger/oauth2-redirect.html" },
PostLogoutRedirectUris = { $"{configuration["WebhooksApiClient"]}/swagger/" },

AllowedScopes =
{
"webhooks"
}
AllowedScopes =
{
"webhooks"
}
};
}
}
};
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace eShop.Identity.API.Models.AccountViewModels
namespace eShop.Identity.API.Models.AccountViewModels;

public record ForgotPasswordViewModel
{
public record ForgotPasswordViewModel
{
[Required]
[EmailAddress]
public string Email { get; init; }
}
[Required]
[EmailAddress]
public string Email { get; init; }
}
13 changes: 6 additions & 7 deletions src/Identity.API/Models/AccountViewModels/LoggedOutViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
namespace eShop.Identity.API.Models.AccountViewModels
namespace eShop.Identity.API.Models.AccountViewModels;

public record LoggedOutViewModel
{
public record LoggedOutViewModel
{
public string PostLogoutRedirectUri { get; init; }
public string ClientName { get; init; }
public string SignOutIframeUrl { get; init; }
}
public string PostLogoutRedirectUri { get; init; }
public string ClientName { get; init; }
public string SignOutIframeUrl { get; init; }
}
Loading
Loading