UI ダッシュボードの認証と権限

これは何か?

どうやってUI認証を有効にするか?

  1. 設定ファイル gear.confを変更し、gearpump-ui.gearpump.ui-security.authentication-enabledのエントリを見つけ、値をtrueに変更します。

    gearpump-ui.gearpump.ui-security.authentication-enabled = true
    

    UIダッシュボードを再起動し、UI認証を有効にします。ユーザ名とパスワードを入力するように促すでしょう。

Gearpump UIサーバはどれだけの数の認証メソッドをサポートするか?

現在のところ、以下をサポートします:

  1. ユーザ名-パスワードに基づいた認証と
  2. OAuth2に基づいた認証。

ユーザ-パスワードに基づいた認証は、gearpump-ui.gearpump.ui-security.authentication-enabledの場合に有効になり、無効にすることはできません

UI サーバ管理はauxiliary OAuth2 認証チャンネルを有効にするようにも選択できます。

ユーザ-パスワードに基づいた認証

ユーザ-パスワードに基づいた認証は、ユーザが明示的にユーザ名とパスワードを入力を要求するすべての認証のシナリオをカバーします。

Gearpumpは、設定ファイル内に格納されたユーザ名とパスワードのハッシュコードに対して検証を行う組み込みの ConfigFileBasedAuthenticatorを提供します。

しかし、開発者は独自のユーザ-パスワードに基づいた認証、LDAPのサポート、およびデータベースに基づいた認証...を提供するためにio.gearpump.security.Authenticator を継承するために選択することができます。

ConfigFileBasedAuthenticator: 組み込みのユーザ-パスワード認証

ConfigFileBasedAuthenticatorは設定ファイル gear.confに全てのユーザ名とパスワードのハッシュコードを格納します。以下は ConfigFileBasedAuthenticatorを設定するステップです。

ユーザをどうやって追加または削除しますか?

デフォルトの認証プラグインのために、3つのカテゴリを持ちます: admins, users と guests。

System administrator は設定ファイル conf/gear.confを更新することでユーザを追加または削除することができます。

administratorとしてユーザ jerry を追加したいとします。以下はそのステップです:

  1. パスワードを取り上げ、このパスワードのダイジェストを生成します。パスワード ilovegearpump を使うといます。ダイジェストを生成するには:

    bin/gear io.gearpump.security.PasswordUtil -password  ilovegearpump
    

    このようなダイジェスト値を生成するでしょう:

    CgGxGOxlU8ggNdOXejCeLxy+isrCv0TrS37HwA==
    
  2. パス gearpump-ui.gearpump.ui-security.config-file-based-authenticator.admins にある設定ファイル conf/gear.conf を変更し、このリスト内にユーザ jerry を追加します:

    admins = {
       ## Default Admin. Username: admin, password: admin
       ## !!!セキュリティ上の理由でプロダクションクラスタについてはこの組み込みのアカウントを置き換えてください。!!!
       "admin" = "AeGxGOxlU8QENdOXejCeLxy+isrCv0TrS37HwA=="
       "jerry" = "CgGxGOxlU8ggNdOXejCeLxy+isrCv0TrS37HwA=="
    }
    
  3. 変更を有効にするために、bin/servicesを使ってUIダッシュボードを再起動します。

  4. グループ "admins" はとても制限無しのパーミッションを持ち、そのパーミッションを制限したいかも知れません。この場合、 gearpump-ui.gearpump.ui-security.config-file-based-authenticator.users あるいは gearpump-ui.gearpump.ui-security.config-file-based-authenticator.guestsを修正することができます。

  5. さらに詳しい情報を見つけるには conf/gear.conf にある説明を見てください。

デフォルトのユーザとパスワードは何か?

ConfigFileBasedAuthenticator に関して、Gearpump配布物は二つのデフォルトのユーザと一緒に出荷されます:

  1. ユーザ名: admin, パスワード: admin
  2. ユーザ名: guest, パスワード: guest

ユーザadmin は無制限のパーミッションを持ち、一方でguest はアプリケーションのステータスのみを見ることができます。

セキュリティ上の理由で、プロダクションでのクラスタについてはデフォルトのユーザadmin およびguestは削除する必要があります。

これはsecureですか?

まず、自身がパスワードを知るユーザのみで、どのような方法でもいかなるパスワードも格納しないでしょう。ユーザ入力パスワードを検証するために一方向性ハッシュダイジェストを使用するでしょう。

LDAP, Database などのための独自のユーザ-パスワード認証の開発の仕方

開発者が彼/彼女の独自のユーザ-パスワードに基づいた認証を定義することを選択した場合、ユーザが設定オプションを修正する必要があります:

## "io.gearpump.security.CustomAuthenticator" と実際の認証クラスを置きかえます。
gearpump.ui-security.authenticator = "io.gearpump.security.CustomAuthenticator"

CustomAuthenticator が interface を継承するようにします : ```scala trait Authenticator {

def authenticate(user: String, password: String, ec: ExecutionContext): Future[AuthenticationResult] } ```

OAuth2に基づいた認証

OAuth2に基づいた認証は一般的にソーシャルネットワークアカウントと愛想が良いソーシャルログインを達成するために使われます。

Gearpump はユーザが新しい認証ソースをサポートするように拡張することができる一般的なOAuth2認証サポートを提供します。

基本的に、OAuth2に基づいた認証は以下のステップを含みます: 1. ユーザはGearpump UI webサイトへアクセスし、OAuth2サーバにログインするように選択します。 2. Gearpump UI webサイトはユーザをOAuth2 サーバドメイン認証のエンドポイントにリダイレクトします。3. エンドユーザはOAuth2サーバのドメインの中での認証を完了します。4. OAuth2 サーバはユーザをGearpump UI サーバにリダイレクトします。5. Gearpump UI サーバはトークンを検証し、クエリパラメータとフォームフィールドから証明書を抽出します。

専門用語

client Id および client secret のような単語については、ガイドRFC 6749を参照してください

UIサーバのためのwebプロキシを有効化

OAuth2 認証を有効にするには、幾つかのリクエストは直接Gearpump UIサーバの中で継承されるため、Gearpump UIサーバはOAuth2サーバへのネットワークアクセスを持つようにしなければなりません。つまり、ファイヤウォールの後ろにいろ場合は、UIサーバのためのプロキシプロパティを設定しなければなりません。

Windows上の場合

  > set JAVA_OPTS=-Dhttp.proxyHost=xx.com -Dhttp.proxyPort=8088 -Dhttps.proxyHost=xx.com -Dhttps.proxyPort=8088
  > bin\services

Linux上の場合

  $ export JAVA_OPTS="-Dhttp.proxyHost=xx.com -Dhttp.proxyPort=8088 -Dhttps.proxyHost=xx.com -Dhttps.proxyPort=8088"
  $ bin/services

Google Plus OAuth2 認証

Google Plus OAuth2 Authenticator は Google OAuth2 サービスとの認証を行います。証明書としてGoogleユーザプロフィールからメールアドレスを抽出します。

Google OAuth2 Authenticator を使うためには、いくつかのステップがあります:

  1. アプリケーション(ここではGearpump UI サーバ)をアプリケーションとしてGoogle 開発コンソールに登録します。
  2. gear.confに Google OAuth2 情報を設定します
  3. 当てはまる場合は、Gearpump UI サーバのためにネットワークプロキシを設定します。

ステップ1 : webサイトをGoogle上の OAuth2 アプリケーションとして登録する

  1. webサイトを表すアプリケーションをhttps://console.developers.google.comで生成する
  2. 生成したアプリケーションの "API Manager"の中で、API "Google+ API" を有効にする
  3. このアプリケーションのための OAuth client ID を生成する。"API Manager"の"Credential"タブの中で、"Create credentials"を選択し、OAuth client IDを選択します。callback URLを設定するためにウィザードに従い、client IDとclient Secretを生成します。

注意: Callback URL は任意ではありません。

ステップ2: gear.conf内の OAuth2 情報を設定

  1. gearpump.ui-security.oauth2-authenticator-enabled をtrueに設定することで、OAuth2認証を有効にする。
  2. gear.confのgearpump.ui-security.oauth2-authenticators.google セクションを設定する。クラス名、client ID、client Secret および callback URLが適切に設定されるように注意してください。

注意: ここでCallback URL に設定されたものはステップ1のGoogleで設定したものと一致しなければなりません。

ステップ3: 当てはまる場合はネットワークプロキシを設定する。

OAuth2 認証を有効にするには、幾つかのリクエストは直接Gearpump UIサーバの中で継承されるため、Gearpump UIサーバはGoogleサービスへのネットワークアクセスを持つようにしなければなりません。つまり、ファイヤウォールの後ろにいろ場合は、UIサーバのためのプロキシプロパティを設定しなければなりません。

UIサーバのためのwebプロキシの設定方法のガイドについては、上の"UIサーバのためのwebプロキシを有効にする"セクションを参照してください。

ステップ4: UIサーバを再起動し、UIサーバ上のGoogleログインアイコンをクリックしてみてください。

CloudFoundry UAA server OAuth2 Authenticator

CloudFoundryUaaAuthenticatorは CloudFoundry UAA OAuth2 サービスを使って認証を行います。証明書としてGoogleユーザプロフィールからメールアドレスを抽出します。

UAA(ユーザアカウントおよび認証サービス)が何であるかについては、ガイドを見てください: UAA

Google OAuth2 Authenticator を使うためには、いくつかのステップがあります:

  1. ヘルパーツールuaacを使ってアプリケーション (ここでは Gearpump UI サーバ)をアプリケーションとしてUAAに登録する。
  2. gear.confに Google OAuth2 情報を設定します
  3. 当てはまる場合は、Gearpump UI サーバのためにネットワークプロキシを設定します。

ステップ1: uaacを使ってアプリケーションをUAAに登録する

  1. uaacについてhttps://docs.cloudfoundry.org/adminguide/uaa-user-management.htmlでチュートリアルをチェックしてください
  2. bashシェルを開き、コマンド uaac target uaac target [your uaa server url] によってUAAサーバを設定します
  3. 以下の方法でユーザadminとしてログインする

      uaac token client get admin -s MyAdminPassword
    
  4. UAA内で新しいアプリケーション(Client)を生成する uaac client add [your_client_id] --scope "openid cloud_controller.read" --authorized_grant_types "authorization_code client_credentials refresh_token" --authorities "openid cloud_controller.read" --redirect_uri [your_redirect_url] --autoapprove true --secret [your_client_secret]

ステップ2: gear.conf内の OAuth2 情報を設定

  1. gearpump.ui-security.oauth2-authenticator-enabled をtrueに設定することで、OAuth2認証を有効にする。
  2. gearpump.ui-security.oauth2-authenticators.cloudfoundryuaaの章に遷移する
  3. gear.confの gearpump.ui-security.oauth2-authenticators.cloudfoundryuaa セクションを設定する。クラス名、client ID、client Secret および callback URLが適切に設定されるように注意してください。

注意: ここでの callback URLはステップ1での CloudFoundry UAAで設定したものと一致しなければなりません。

ステップ3: 当てはまる場合は、Gearpump UI サーバのためにネットワークプロキシを設定します

OAuth2 認証を有効にするには、幾つかのリクエストは直接Gearpump UIサーバの中で継承されるため、Gearpump UIサーバはGoogleサービスへのネットワークアクセスを持つようにしなければなりません。つまり、ファイヤウォールの後ろにいろ場合は、UIサーバのためのプロキシプロパティを設定しなければなりません。

UIサーバのためのwebプロキシの設定方法のガイドについては、上の"UIサーバのためのwebプロキシを有効にする"セクションを参照してください。

ステップ4: UIサーバを再起動し、UIサーバ上のCloudFoundryログインアイコンをクリックしてみてください。

ステップ5: 以下の設定をすることで、CloudFoundry UAAのための追加の認証を有効にすることもできます:

additional-authenticator-enabled = true

更なる情報については、gear.confの説明を見てください。

Facebook あるいは Twitterのような新しい認証サービスのサポートをするために OAuth2Authenticator を拡張する。

独自のOAuth2Authenticatorを定義するために Google OAuth2のコード例に従うことができます。 基本的に、ステップは以下のものを含みます:

  1. OAuth2Authenticator 実装を定義する。

    /**
     *
     * Uses OAuth2 social-login as the mechanism for authentication.
     * @see [[https://tools.ietf.org/html/rfc6749]] to find what is OAuth2, and how it works.
     *
     * Basically flow for OAuth2 Authentication:
     * 1. ユーザはGearpump UI webサイトにアクセスし、OAuth2サーバを使ってログインすることを選択します。
     * 2. Gearpump UI webサイトはユーザをOAuth2 サーバドメイン認証のエンドポイントにリダイレクトします。 * 3. ユーザはOAuth2サーバのドメイン内での認証を完了します。
     * 4. OAuth2 サーバはユーザを Gearpump UI sa-ba にリダイレクトします。
     * 5. Gearpump UI サーバはトークンを検証し、クエリから証明書を抽出します
     * parameters and form fields.
     *
     * @note '''Thread-safety''' is a MUST requirement. 開発者はサブクラスがスレッドセーフであることを確実にする必要があります。
     * Sub-class should have a parameterless constructor.
     *
     * @note OAuth2 Authenticator requires access of Internet. Please make sure HTTP proxy are
     * set properly if applied.
     *
     * @example Config proxy when UI server is started on Windows:
     * }
     *
     * @example Config proxy when UI server is started on Linux:
     * }
     *
     */
    trait OAuth2Authenticator {
    
      /**
       * Inits authenticator with config which contains client ID, client secret, and etc..
       *
       * Typically, the client key and client secret is provided by OAuth2 Authorization server when user
       * register an application there.
       * @see [[https://tools.ietf.org/html/rfc6749]] for definition of client, client Id,
       * and client secret.
       *
       * See [[https://developer.github.com/v3/oauth/]] for an actual example of how Github
       * use client key, and client secret.
       *
       * @note '''Thread-Safety''': Framework ensures this call is synchronized.
       *
       * @param config Client Id, client secret, callback URL and etc..
       */
      def init(config: Config): Unit
    
      /**
       * Returns the OAuth Authorization URL so for redirection to that address to do OAuth2
       * authorization.
       *
       * @note '''Thread-Safety''': This can be called in a multi-thread environment. Developer
       *      need to ensure thread safety.
       */
      def getAuthorizationUrl: String
    
      /**
       * After authorization, OAuth2 server redirects user back with tokens. This verify the
       * tokens, retrieve the profiles, and return [[UserSession]] information.
       *
       * @note This is an Async call.
       * @note This call requires external internet access.
       * @note '''Thread-Safety''': This can be called in a multi-thread environment. Developer
       *      need to ensure thread safety.
       *
       * @param parameters HTTP Query and Post parameters, which typically contains Authorization code.
       * @return UserSession if pass authentication.
       */
      def authenticate(parameters: Map[String, String]): Future[UserSession]
    
      /**
       * Clean resource
       */
      def close(): Unit
    }
  2. gearpump.ui-security.oauth2-authenticatorsの下の設定エントリを追加します。例えば:

     ## name of this authenticator
    "socialnetworkx" {
      "class" = "io.gearpump.services.security.oauth2.impl.SocialNetworkXAuthenticator"
    
      ## Please make sure this URL matches the name
      "callback" = "http://127.0.0.1:8090/login/oauth2/socialnetworkx/callback"
    
      "clientId" = "gearpump_test2"
      "clientSecret" = "gearpump_test2"
      "defaultUserRole" = "guest"
    
      ## Make sure socialnetworkx.png exists under dashboard/icons
      icon = "/icons/socialnetworkx.png"
    }
    

    設定のエントリはクラスSocialNetworkXAuthenticatorによって使われるとみなすことができます。

TOP
inserted by FC2 system