ASP.NETコア分散型プロジェクトの戦闘(ビジネス、アーキテクチャ設計、のOAuth2、IdentityServer4) - 研究ノート

タスク4:章計画とディレクトリ

  • アジャイル製品開発プロセス
  • プロトタイプのプレビューとビジネス
  • 全体的なアーキテクチャの設計
  • APIインターフェイスのデザイン/闊歩
  • Identity Serverの4ログインのビルド
  • アカウントAPIの実装
  • コンフィギュレーション・センター

タスク5:ビジネス

プロジェクトの背景:プロジェクトの金融業界での接続に基づいて、

ユーザー:

1、口座番号:

  • 基本的なメンテナンス
  • ログイン

2、自分のプロジェクトを管理

  • 作ります
  • シェア(可視範囲)
  • スティッキー
  • ビュープロジェクトの進捗状況

3、誰か他の人のプロジェクトの紹介

  • 友達の項目を参照してください。
  • 二度の連絡先のプロジェクトを見ます
  • システム推奨項目を見ます
  • 他の人のプロジェクトを見ます
  • プロジェクトに関わるその他

図4に示すように、メッセージ:

  • チャットメッセージ
  • システムメッセージ

5人の友達:

  • 追加フレンド(インポートアドレス帳、友人のための電話番号検索)

タスク6:建築設計

タスク7:のOAuth2はじめに

OAuthのは、認可(承認)のためのオープンなネットワーク規格であります

ライセンスの4種類:

  • 認証コードモード
  • 簡易モード
  • パスワードモード
  • クライアントモード

OAuth 2.0のを理解します:

https://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html

タスク8:IdentityServer4ログインセンター

新プロジェクト

dotnet new webapi --name IdentityServerCenter

IdentityServer4:Nugetパッケージを追加します

VSコードnugetをインストールする方法:

https://blog.csdn.net/qq_36051316/article/details/84106418

なぜ、インストールが失敗し、解決策:

vscode問題nugetプラグインを使用することはできませんを解決します:

https://www.cnblogs.com/lori/p/11651079.html

Visual StudioのソリューションNuGetの接続は、パッケージの公式ソースではありません。

https://blog.csdn.net/weixin_34161083/article/details/85764761

設定スタートアップ設定

参照の追加

using IdentityServer4;

登録サービス

services.AddIdentityServer()
        .AddDeveloperSigningCredential();

サービスを使用します

app.UseIdentityServer();

Program.csの中、開始ポートを設定します

webBuilder.UseUrls("http://localhost:5000");

IdentityServer4初期化、コンフィギュレーション・クラスConfig.csを追加

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

namespace IdentityServerCenter
{
    public class Config
    {
        public static IEnumerable<ApiResource> GetResource()
        {
            return new List<ApiResource>
            {
                new ApiResource("api", "My Api")
            };
        }

        public static IEnumerable<Client> GetClients()
        {
            return new List<Client>
            {
                new Client()
                {
                    ClientId = "client",
                    AllowedGrantTypes = GrantTypes.ClientCredentials,
                    ClientSecrets = 
                    {
                        new Secret("secret".Sha256())
                    },
                    AllowedScopes = {"api"},
                }
            };
        }
    }
}

設定はIdentityServer4を変更します

services.AddIdentityServer()
        .AddDeveloperSigningCredential()
        .AddInMemoryApiResources(Config.GetResource())
        .AddInMemoryClients(Config.GetClients());

ランチャー

dotnet run

アクセスアドレス

http://localhost:5000/.well-known/openid-configuration

(JSON形式)結果は次のとおりであります

{
    "issuer": "http://localhost:5000",
    "jwks_uri": "http://localhost:5000/.well-known/openid-configuration/jwks",
    "authorization_endpoint": "http://localhost:5000/connect/authorize",
    "token_endpoint": "http://localhost:5000/connect/token",
    "userinfo_endpoint": "http://localhost:5000/connect/userinfo",
    "end_session_endpoint": "http://localhost:5000/connect/endsession",
    "check_session_iframe": "http://localhost:5000/connect/checksession",
    "revocation_endpoint": "http://localhost:5000/connect/revocation",
    "introspection_endpoint": "http://localhost:5000/connect/introspect",
    "device_authorization_endpoint": "http://localhost:5000/connect/deviceauthorization",
    "frontchannel_logout_supported": true,
    "frontchannel_logout_session_supported": true,
    "backchannel_logout_supported": true,
    "backchannel_logout_session_supported": true,
    "scopes_supported": [
        "api",
        "offline_access"
    ],
    "claims_supported": [],
    "grant_types_supported": [
        "authorization_code",
        "client_credentials",
        "refresh_token",
        "implicit",
        "urn:ietf:params:oauth:grant-type:device_code"
    ],
    "response_types_supported": [
        "code",
        "token",
        "id_token",
        "id_token token",
        "code id_token",
        "code token",
        "code id_token token"
    ],
    "response_modes_supported": [
        "form_post",
        "query",
        "fragment"
    ],
    "token_endpoint_auth_methods_supported": [
        "client_secret_basic",
        "client_secret_post"
    ],
    "id_token_signing_alg_values_supported": [
        "RS256"
    ],
    "subject_types_supported": [
        "public"
    ],
    "code_challenge_methods_supported": [
        "plain",
        "S256"
    ],
    "request_parameter_supported": true
}

私たちは、ライセンスの4種類を見ることができます:

"grant_types_supported": [
        "authorization_code",
        "client_credentials",
        "refresh_token",
        "implicit",
        "urn:ietf:params:oauth:grant-type:device_code"
    ],

コースリンク

http://video.jessetalk.cn/course/explore

クリエイティブコモンズライセンス

この作品は、ある非営利- -同一条件許諾4.0の国際ライセンス契約クリエイティブ・コモンズのライセンスのために。

転載、使用、再投稿へようこそますが、(リンクを含む:鄭Zimingによって署名記事を保つために必ずhttp://www.cnblogs.com/MingsonZheng/を)、商業目的のために使用してはならない、紙のライセンス変更に基づいて、同じ作業を公開してください。

ご質問があれば、私に連絡してください([email protected])。

おすすめ

転載: www.cnblogs.com/MingsonZheng/p/12630155.html