Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Терзиогло, Кононов, Хлопина #26

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
48 changes: 37 additions & 11 deletions IdentityServer/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using IdentityServer4.Models;
using System.Collections.Generic;
using IdentityServer4;

namespace IdentityServer
{
Expand All @@ -12,42 +13,67 @@ public static class Config
public static IEnumerable<IdentityResource> Ids =>
new IdentityResource[]
{
new IdentityResources.OpenId()
new IdentityResources.OpenId(),
new IdentityResources.Profile(),
new IdentityResources.Email()
};

public static IEnumerable<ApiResource> Apis =>
new ApiResource[]
{
new ApiResource("api1", "My API")
new ApiResource("photos_service", "Сервис фотографий")
{
Scopes = { "scope1" }
Scopes = { "photos" }
}
};

public static IEnumerable<ApiScope> ApiScopes =>
new ApiScope[]
{
new ApiScope("scope1", "My scope")
new ApiScope("photos", "Фотографии")
};

public static IEnumerable<Client> Clients =>
new Client[]
{
new Client
{
ClientId = "client",
ClientId = "Photos App by OAuth",
ClientSecrets =
{
new Secret("secret".Sha256())
},

// no interactive user, use the clientid/secret for authentication
AllowedGrantTypes = GrantTypes.ClientCredentials,
AllowedScopes = { "photos" }
},
new Client
{
ClientId = "Photos App by OIDC",
ClientSecrets = { new Secret("secret".Sha256()) },

// secret for authentication
ClientSecrets =
AllowedGrantTypes = GrantTypes.Code,

// NOTE: показывать ли пользователю страницу consent со списком запрошенных разрешений
RequireConsent = false,

// NOTE: куда отправлять после логина
RedirectUris = { "https://localhost:5001/signin-passport" },

AllowedScopes = new List<string>
{
new Secret("secret".Sha256())
// NOTE: Позволяет запрашивать id token
IdentityServerConstants.StandardScopes.OpenId,
// NOTE: Позволяет запрашивать профиль пользователя через id token
IdentityServerConstants.StandardScopes.Profile,
// NOTE: Позволяет запрашивать email пользователя через id token
IdentityServerConstants.StandardScopes.Email
},

// scopes that client has access to
AllowedScopes = { "scope1" }
// NOTE: Надо ли добавлять информацию о пользователе в id token при запросе одновременно
// id token и access token, как это происходит в code flow.
// Либо придется ее получать отдельно через user info endpoint.
AlwaysIncludeUserClaimsInIdToken = true,
}
};
}
Expand Down
Loading