Apigee SSO をインストールして構成する

Apigee SSO モジュールをインストールして外部 IDP を使用するように構成するには、次のことを行う必要があります。

  1. 鍵と証明書を作成する
  2. 基本的な Apigee SSO 構成を設定する: ベースファイルに、すべての SSO 構成に共通のプロパティを含める必要があります。
  3. IDP 固有の構成プロパティを追加する: 次に示す IDP 固有の構成プロパティ ブロックのいずれか 1 つを構成ファイルに追加します。
  4. Apigee SSO をインストールする: インストーラに構成ファイルを渡して Apigee SSO モジュールをインストールします。

それぞれの手順は、次のセクションで説明します。

鍵と証明書を作成する

このセクションでは、自己署名証明書を作成する方法について説明します。テスト環境では自己署名証明書で十分ですが、本番環境では必ず認証局(CA)によって署名された証明書を使用してください。

検証のために署名する鍵ペアを作成するには:

  1. sudo ユーザーとして、次の新しいディレクトリを作成します。
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/jwt-keys
  2. 新しいディレクトリに移動します。
    cd /opt/apigee/customer/application/apigee-sso/jwt-keys/
  3. 次のコマンドを使用して秘密鍵を生成します。
    sudo openssl genrsa -out privkey.pem 2048
  4. 次のコマンドを使用して、秘密鍵から公開鍵を生成します。
    sudo openssl rsa -pubout -in privkey.pem -out pubkey.pem
  5. 出力された PEM ファイルの所有者を「apigee」ユーザーに変更します。
    sudo chown apigee:apigee *.pem

IDP との通信に使用する鍵と自己署名証明書をパスフレーズなしで作成するには:

  1. sudo ユーザーとして、新しいディレクトリを作成します。
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/idp/
  2. 新しいディレクトリに移動します。
    cd /opt/apigee/customer/application/apigee-sso/idp/
  3. パスフレーズ付きの秘密鍵を生成します。
    sudo openssl genrsa -out server.key 2048
  4. 秘密鍵からパスフレーズを削除します。
    sudo openssl rsa -in server.key -out server.key
  5. CA の証明書署名リクエストを生成します。
    sudo openssl req -x509 -sha256 -new -key server.key -out server.csr
  6. 有効期限が 365 日の自己署名証明書を生成します。
    sudo openssl x509 -sha256 -days 365 -in server.csr -signkey server.key -out selfsigned.crt
  7. 鍵と証明書をキーストアにエクスポートします。
    1. 鍵と証明書を PKCS12 キーストアにエクスポートします。
    2. sudo openssl pkcs12 -export -clcerts -in <certificate_path> -inkey <key_path> -out <keystore_path> -name <alias>

      パラメータ:

      • certificate_path: 手順 6 で作成した証明書のパス。
      • key_path: ステップ 3 で生成された秘密鍵のパス。
      • keystore_path: 証明書と秘密鍵を含む新しく作成された PKCS12 キーストアのパス。
      • alias: キーストア内の鍵と証明書のペアを参照するために使用されるエイリアス。

      詳細については、OpenSSL のドキュメントをご覧ください。

    3. (省略可)鍵と証明書を PKCS12 から JKS キーストアにエクスポートします。
    4. sudo keytool -importkeystore -srckeystore <PKCS12_keystore_path> -srcstoretype PKCS12 
      -destkeystore <destination_keystore_path> -deststoretype JKS -alias <alias>

      パラメータ:

      • PKCS12_keystore_path: 証明書と秘密鍵を含む、手順 7 で作成した PKCS12 キーストアのパス。
      • destination_keystore_path: 同じ証明書と鍵を含む新しく作成された JKS キーストアのパス。
      • alias: JKS キーストア内の鍵と証明書のペアに使用されるエイリアス。

      詳細については、keytool のドキュメントをご覧ください。

    5. 出力キーストア ファイルの所有者を「apigee」ユーザーに変更します。
      sudo chown apigee:apigee <keystore_file>
    6. silent.conf で次のプロパティを更新します。
    7. # Path to your keystore  
      SSO_SAML_SERVICE_PROVIDER_KEYSTORE_PATH=/opt/apigee/customer/application/apigee-sso/saml/keystore.p12  
      
      # Keystore password
      SSO_SAML_SERVICE_PROVIDER_KEYSTORE_PASSWORD=Secret123
      
      # Alias within keystore that stores the key and certificate  
      SSO_SAML_SERVICE_PROVIDER_KEYSTORE_ALIAS=service-provider-cert  
      
      # [Optional] Only specify if you are using something other than JKS. Values could be PKCS12 or BCFKS  
      SSO_SAML_SERVICE_PROVIDER_KEYSTORE_TYPE=JKS

    Apigee SSO モジュールで SSO_TOMCAT_PROFILESSL_TERMINATION または SSL_PROXY に設定して TLS を有効にするときには、自己署名証明書を使用できません。CA からの証明書を生成する必要があります。詳細については、Apigee SSO への HTTPS アクセスを構成するをご覧ください。

    Apigee SSO 構成の設定

    Apigee SSO モジュールをインストールする前に、構成ファイルを定義する必要があります。この構成ファイルは、Apigee SSO モジュールをインストールするときにインストーラに渡します。

    構成ファイルの形式は次のとおりです。

    IP1=hostname_or_IP_of_apigee_SSO
    IP2=hostname_or_IP_of_apigee_SSO
    
    ## Management Server configuration.
    # Management Server IP address and port
    MSIP=$IP1
    MGMT_PORT=8080
    # Edge sys admin username and password as set when you installed Edge.
    ADMIN_EMAIL=opdk@google.com
    APIGEE_ADMINPW=Secret123
    # Set the protocol for the Edge management API. Default is http.
    # Set to https if you enabled TLS on the management API.
    MS_SCHEME=http
    
    ## Postgres configuration.
    # Postgres IP address and port
    PG_HOST=$IP1
    PG_PORT=5432
    # Postgres username and password as set when you installed Edge.
    PG_USER=apigee
    PG_PWD=postgres
    
    ## Apigee SSO module configuration.
    # Choose either "saml" or "ldap".
    SSO_PROFILE="[saml|ldap]"
    # Externally accessible IP or DNS name of apigee-sso.
    SSO_PUBLIC_URL_HOSTNAME=$IP2
    SSO_PG_DB_NAME=database_name_for_sso
    
    # Default port is 9099. If changing, set both properties to the same value.
    SSO_PUBLIC_URL_PORT=9099
    SSO_TOMCAT_PORT=9099
    # Set Tomcat TLS mode to DEFAULT to use HTTP access to apigee-sso.
    SSO_TOMCAT_PROFILE=DEFAULT
    SSO_PUBLIC_URL_SCHEME=http
    
    # SSO admin user name. The default is ssoadmin.
    SSO_ADMIN_NAME=ssoadmin
    # SSO admin password using uppercase, lowercase, number, and special chars.
    SSO_ADMIN_SECRET=Secret123
    
    # Enable the ability to sign an authentication request with SAML SSO.
    SSO_SAML_SIGN_REQUEST=y
    
    # Path to signing key and secret from Create the TLS keys and certificates above.
    SSO_JWT_SIGNING_KEY_FILEPATH=/opt/apigee/customer/application/apigee-sso/jwt-keys/privkey.pem
    SSO_JWT_VERIFICATION_KEY_FILEPATH=/opt/apigee/customer/application/apigee-sso/jwt-keys/pubkey.pem
    
    ###########################################################
    #                 Define External IDP                     #
    # Use one of the following configuration blocks to        #
    # define your IDP settings:                               #
    #  - SAML configuration properties                     #
    #  - LDAP Direct Binding configuration properties        #
    #  - LDAP Indirect Binding configuration properties       #
    ###########################################################
    
    INSERT_IDP_CONFIG_BLOCK_HERE (SAML, LDAP direct, or LDAP indirect, below)
    
    # Configure an SMTP server so that the Apigee SSO module can send emails to users
    SKIP_SMTP=n
    SMTPHOST=smtp.example.com
    SMTPUSER=smtp@example.com
    # omit for no username
    SMTPPASSWORD=smtppwd
    # omit for no password
    SMTPSSL=n
    SMTPPORT=25
    # The address from which emails are sent
    SMTPMAILFROM="My Company <myco@company.com>"

    SAML SSO 構成プロパティ

    IDP に SAML を使用する場合は、次の構成プロパティのブロックを(上記で定義した)構成ファイルに追加します。

    ## SAML Configuration Properties
    # Insert this section into your base configuration file, as described previously.
    
    # Name of SAML IDP. For example, okta or adfs.
    SSO_SAML_IDP_NAME=okta
    # Text displayed on the SSO sign-in page after being redirected by either the New or Classic Edge UI for SAML logins.
    # Note: Installing SSO does not depend on the Edge UI or which version of the UI you are using.
    SSO_SAML_IDP_LOGIN_TEXT="Please log in to your IDP"
    
    # The metadata URL from your IDP.
    # If you have a metadata file, and not a URL,
    # see "Specifying a metadata file instead of a URL" below.
    SSO_SAML_IDP_METADATA_URL=https://dev-343434.oktapreview.com/app/exkar20cl/sso/saml/metadata
    
    # Determines whether to skip TLS validation for the URL specified
    # by SSO_SAML_IDP_METADATA_URL.
    # This is necessary if the URL uses a self-signed certificate.
    # The default value is "n".
    SSO_SAML_IDPMETAURL_SKIPSSLVALIDATION=n
    
    # Keystore configuration details
    # [Optional] Only specify KEYSTORE_TYPE if you are using something other than JKS. Values could be PKCS12 or BCFKS.
    SSO_SAML_SERVICE_PROVIDER_KEYSTORE_PATH=/opt/apigee/customer/application/apigee-sso/saml/keystore.jks
    SSO_SAML_SERVICE_PROVIDER_KEYSTORE_PASSWORD=Secret123
    SSO_SAML_SERVICE_PROVIDER_KEYSTORE_ALIAS=service-provider-cert
    SSO_SAML_SERVICE_PROVIDER_KEYSTORE_TYPE=JKS
    
    # Requires that SAML responses be signed by your IDP.
    # This property is enabled by default since release 4.50.00.05.
    SSO_SAML_SIGNED_ASSERTIONS=y

    LDAP 直接バインディング構成プロパティ

    IDP に LDAP 直接バインディングを使用する場合は、上記の例と同様に、次の構成プロパティのブロックを構成ファイルに追加します。

    ## LDAP Direct Binding configuration
    # Insert this section into your base configuration file, as described previously.
    
    # The type of LDAP profile; in this case, "direct"
    SSO_LDAP_PROFILE=direct
    
    # The base URL to which SSO connects; in the form: "ldap://hostname_or_IP:port
    SSO_LDAP_BASE_URL=LDAP_base_URL
    
    # Attribute name used by the LDAP server to refer to the user's email address; for example, "mail"
    SSO_LDAP_MAIL_ATTRIBUTE=LDAP_email_attribute
    
    # Pattern of the user's DN; for example: =cn={0},ou=people,dc=example,dc=org
    # If there is more than one pattern, separate with semicolons (";"); for example:
    # =cn={0},ou=people,dc=example,dc=org;=cn={0},ou=people,dc=example,dc=com
    SSO_LDAP_USER_DN_PATTERN=LDAP_DN_pattern

    LDAP 間接バインディング構成プロパティ

    IDP に LDAP 間接バインディングを使用する場合は、上記の例と同様に、次の構成プロパティのブロックを構成ファイルに追加します。

    ## LDAP Indirect Binding configuration
    # Insert this section into your base configuration file, as described previously.
    
    # Type of LDAP profile; in this case, "indirect"
    SSO_LDAP_PROFILE=indirect
    
    # Base URL to which SSO connects; in the form: "ldap://hostname_or_IP:port
    SSO_LDAP_BASE_URL=LDAP_base_URL
    
    # DN and password of the LDAP server's admin user
    SSO_LDAP_ADMIN_USER_DN=LDAP_admin_DN
    SSO_LDAP_ADMIN_PWD=LDAP_admin_password
    
    # LDAP search base; for example, "dc=example,dc=org"
    SSO_LDAP_SEARCH_BASE=LDAP_search_base
    
    # LDAP search filter; for example, "cn={0}"
    SSO_LDAP_SEARCH_FILTER=LDAP_search_filter
    # LDAP サーバーがユーザーのメールアドレスを参照するために使用する属性名。例: 「mail」 SSO_LDAP_MAIL_ATTRIBUTE=LDAP_email_attribute

    Apigee SSO モジュールをインストールする

    鍵を作成して構成ファイルを準備したら、Apigee SSO モジュールをインストールできます。

    Apigee SSO モジュールをインストールするには:

    1. Management Server ノードにログインします。このノードにはすでに apigee-service がインストールされています(Edge apigee-setup ユーティリティのインストールを参照)。

      または、Apigee SSO モジュールを別のノードにインストールすることもできます。ただし、そのノードがポート 8080 を介して Management Server にアクセスできる状態にある必要があります。

    2. 次のコマンドを実行して、apigee-sso をインストールして構成します。
      /opt/apigee/apigee-setup/bin/setup.sh -p sso -f configFile

      ここで、configFile は上記で定義した構成ファイルです。

    3. apigee-sso モジュールの管理者とマシンユーザーの管理に使用する apigee-ssoadminapi.sh ユーティリティをインストールします。
      /opt/apigee/apigee-service/bin/apigee-service apigee-ssoadminapi install
    4. apigee-ssoadminapi.sh ユーティリティをパスに追加するため、シェルからいったんログアウトして再びログインします。

    URL の代わりにメタデータ ファイルを指定する

    ご利用の IDP が HTTP/HTTPS メタデータ URL をサポートしていない場合は、メタデータ XML ファイルを使用して Apigee SSO を構成できます。

    URL の代わりにメタデータ ファイルを使用して Apigee SSO を構成するには:

    1. ご利用の IDP から提供されているメタデータ XML の内容をコピーして、Apigee SSO ノード上のファイルに貼り付けます。たとえば、次のファイルに XML の内容をコピーします。
      /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    2. XML ファイルの所有者を「apigee」ユーザーに変更します。
      chown apigee:apigee /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    3. SSO_SAML_IDP_METADATA_URL にこのファイルの絶対パスを設定します。
      SSO_SAML_IDP_METADATA_URL=file:///opt/apigee/customer/application/apigee-sso/saml/metadata.xml

      ファイルパスの先頭に「file://」を付け、その後にルート(/)からの絶対パスを続ける必要があります。