Menginstal dan mengonfigurasi Apigee Apigee

Untuk menginstal dan mengonfigurasi modul SSO Apigee dengan IDP eksternal, Anda harus melakukan hal berikut:

  1. Buat kunci dan sertifikat.
  2. Siapkan konfigurasi SSO Apigee dasar: File dasar harus menyertakan properti yang umum untuk semua konfigurasi SSO.
  3. Menambahkan properti konfigurasi khusus IdP: Gunakan salah satu blok properti konfigurasi khusus IdP berikut dalam file konfigurasi Anda:
  4. Instal Apigee SSO: Instal modul Apigee SSO, dan teruskan file konfigurasi ke penginstal.

Setiap langkah ini dijelaskan di bagian selanjutnya.

Membuat kunci dan sertifikat

Bagian ini menjelaskan cara membuat sertifikat yang ditandatangani sendiri yang mungkin tidak masalah untuk lingkungan pengujian, tetapi Anda harus menggunakan sertifikat yang ditandatangani oleh Certificate Authority (CA) untuk lingkungan produksi.

Untuk membuat pasangan kunci yang akan ditandatangani untuk verifikasi:

  1. Sebagai pengguna sudo, buat direktori baru berikut:
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/jwt-keys
  2. Ubah ke direktori baru:
    cd /opt/apigee/customer/application/apigee-sso/jwt-keys/
  3. Buat kunci pribadi dengan perintah berikut:
    sudo openssl genrsa -out privkey.pem 2048
  4. Buat kunci publik dari kunci pribadi dengan perintah berikut:
    sudo openssl rsa -pubout -in privkey.pem -out pubkey.pem
  5. Ubah pemilik file PEM output menjadi pengguna "apigee":
    sudo chown apigee:apigee *.pem

Untuk membuat kunci dan sertifikat yang ditandatangani sendiri, tanpa frasa sandi, untuk berkomunikasi dengan IdP:

  1. Sebagai pengguna sudo, buat direktori baru:
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/idp/
  2. Ubah ke direktori baru:
    cd /opt/apigee/customer/application/apigee-sso/idp/
  3. Buat kunci pribadi dengan frasa sandi:
    sudo openssl genrsa -out server.key 2048
  4. Hapus frasa sandi dari kunci:
    sudo openssl rsa -in server.key -out server.key
  5. Buat permintaan penandatanganan sertifikat untuk CA:
    sudo openssl req -x509 -sha256 -new -key server.key -out server.csr
  6. Buat sertifikat yang ditandatangani sendiri dengan waktu habis masa berlaku 365 hari:
    sudo openssl x509 -sha256 -days 365 -in server.csr -signkey server.key -out selfsigned.crt
  7. Ekspor kunci dan sertifikat ke keystore:
    1. Ekspor kunci dan sertifikat ke keystore PKCS12:
    2. sudo openssl pkcs12 -export -clcerts -in <certificate_path> -inkey <key_path> -out <keystore_path> -name <alias>

      Parameter:

      • certificate_path: Jalur ke sertifikat yang dibuat di Langkah 6.
      • key_path: Jalur ke kunci pribadi yang dibuat di Langkah 3.
      • keystore_path: Jalur ke keystore PKCS12 yang baru dibuat yang berisi sertifikat dan kunci pribadi.
      • alias: Alias yang digunakan untuk mereferensikan pasangan kunci dan sertifikat dalam keystore.

      Lihat dokumentasi OpenSSL untuk detail selengkapnya.

    3. (Opsional) Ekspor kunci dan sertifikat dari PKCS12 ke keystore JKS:
    4. sudo keytool -importkeystore -srckeystore <PKCS12_keystore_path> -srcstoretype PKCS12 
      -destkeystore <destination_keystore_path> -deststoretype JKS -alias <alias>

      Parameter:

      • PKCS12_keystore_path: Jalur ke keystore PKCS12 yang dibuat di Langkah 7 yang berisi sertifikat dan kunci pribadi.
      • destination_keystore_path: Jalur ke keystore JKS yang baru dibuat yang berisi sertifikat dan kunci yang sama.
      • alias: Alias yang digunakan untuk pasangan kunci dan sertifikat dalam keystore JKS.

      Lihat dokumentasi keytool untuk mengetahui detail selengkapnya.

    5. Ubah pemilik file keystore output menjadi pengguna "apigee":
      sudo chown apigee:apigee <keystore_file>
    6. Perbarui properti berikut di 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

    Untuk mengaktifkan TLS di modul SSO Apigee, dengan menetapkan SSO_TOMCAT_PROFILE ke SSL_TERMINATION atau ke SSL_PROXY, Anda tidak dapat menggunakan sertifikat yang ditandatangani sendiri. Anda harus membuat sertifikat dari CA. Lihat Mengonfigurasi SSO Apigee untuk akses HTTPS untuk mengetahui informasi selengkapnya.

    Setelan konfigurasi SSO Apigee

    Sebelum dapat menginstal modul SSO Apigee, Anda harus menentukan file konfigurasi. Anda meneruskan file konfigurasi ini ke penginstal saat menginstal modul SSO Apigee.

    File konfigurasi memiliki bentuk berikut:

    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>"

    Properti konfigurasi SSO SAML

    Jika Anda menggunakan SAML untuk IdP, gunakan blok properti konfigurasi berikut dalam file konfigurasi (ditentukan di atas):

    ## 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

    Properti konfigurasi Binding Langsung LDAP

    Jika Anda menggunakan binding langsung LDAP untuk IdP, gunakan blok properti konfigurasi berikut dalam file konfigurasi, seperti yang ditunjukkan dalam contoh di atas:

    ## 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

    Properti konfigurasi Binding Indirect LDAP

    Jika Anda menggunakan binding tidak langsung LDAP untuk IdP, gunakan blok properti konfigurasi berikut dalam file konfigurasi, seperti yang ditunjukkan dalam contoh di atas:

    ## 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
    # Nama atribut yang digunakan oleh server LDAP untuk merujuk ke alamat email pengguna; misalnya, "mail" SSO_LDAP_MAIL_ATTRIBUTE=LDAP_email_attribute

    Menginstal modul SSO Apigee

    Setelah membuat kunci dan menyiapkan file konfigurasi, Anda dapat menginstal modul SSO Apigee.

    Untuk menginstal modul SSO Apigee:

    1. Login ke node Server Pengelolaan. Node tersebut seharusnya sudah menginstal apigee-service, seperti yang dijelaskan dalam Menginstal utilitas penyiapan apigee Edge.

      Atau, Anda dapat menginstal modul SSO Apigee di node lain. Namun, node tersebut harus dapat mengakses Server Pengelolaan melalui port 8080.

    2. Instal dan konfigurasi apigee-sso dengan menjalankan perintah berikut:
      /opt/apigee/apigee-setup/bin/setup.sh -p sso -f configFile

      Dengan configFile adalah file konfigurasi yang Anda tentukan di atas.

    3. Instal utilitas apigee-ssoadminapi.sh yang digunakan untuk mengelola admin dan pengguna mesin untuk modul apigee-sso:
      /opt/apigee/apigee-service/bin/apigee-service apigee-ssoadminapi install
    4. Logout dari shell, lalu login kembali untuk menambahkan utilitas apigee-ssoadminapi.sh ke jalur Anda.

    Tentukan file metadata, bukan URL

    Jika IdP Anda tidak mendukung URL metadata HTTP/HTTPS, Anda dapat menggunakan file XML metadata untuk mengonfigurasi SSO Apigee.

    Untuk menggunakan file metadata, bukan URL, guna mengonfigurasi SSO Apigee:

    1. Salin konten XML metadata dari IdP Anda ke file di node SSO Apigee. Misalnya, salin XML ke:
      /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    2. Ubah kepemilikan file XML ke pengguna "apigee":
      chown apigee:apigee /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    3. Tetapkan nilai SSO_SAML_IDP_METADATA_URL ke jalur file absolut:
      SSO_SAML_IDP_METADATA_URL=file:///opt/apigee/customer/application/apigee-sso/saml/metadata.xml

      Anda harus menambahkan awalan ke jalur file dengan "file://", diikuti dengan jalur absolut dari root (/).