Cài đặt và định cấu hình Apigee SSO

Để cài đặt và định cấu hình mô-đun SSO Apigee bằng một IDP bên ngoài, bạn phải làm như sau:

  1. Tạo khoá và chứng chỉ.
  2. Thiết lập cấu hình SSO cơ sở của Apigee: Tệp cơ sở phải bao gồm các thuộc tính phổ biến cho tất cả cấu hình SSO.
  3. Thêm thuộc tính cấu hình dành riêng cho IDP: Sử dụng một trong các khối thuộc tính cấu hình dành riêng cho IDP sau đây trong tệp cấu hình:
  4. Cài đặt Apigee SSO: Cài đặt mô-đun Apigee SSO và chuyển tệp cấu hình đến trình cài đặt.

Mỗi bước được mô tả cụ thể trong phần tiếp theo.

Tạo khoá và chứng chỉ

Phần này mô tả cách tạo chứng chỉ tự ký. Chứng chỉ này có thể phù hợp với môi trường thử nghiệm, nhưng bạn nên sử dụng chứng chỉ do Tổ chức phát hành chứng chỉ (CA) ký cho môi trường phát hành chính thức.

Cách tạo cặp khoá để ký xác minh:

  1. Với tư cách là người dùng sudo, hãy tạo thư mục mới sau:
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/jwt-keys
  2. Thay đổi sang thư mục mới:
    cd /opt/apigee/customer/application/apigee-sso/jwt-keys/
  3. Tạo khoá riêng tư bằng lệnh sau:
    sudo openssl genrsa -out privkey.pem 2048
  4. Tạo khoá công khai từ khoá riêng tư bằng lệnh sau:
    sudo openssl rsa -pubout -in privkey.pem -out pubkey.pem
  5. Thay đổi chủ sở hữu của tệp PEM đầu ra thành người dùng "apigee":
    sudo chown apigee:apigee *.pem

Để tạo khoá và chứng chỉ tự ký, không có cụm mật khẩu, nhằm giao tiếp với IDP:

  1. Với tư cách là người dùng sudo, hãy tạo một thư mục mới:
    sudo mkdir -p /opt/apigee/customer/application/apigee-sso/idp/
  2. Thay đổi sang thư mục mới:
    cd /opt/apigee/customer/application/apigee-sso/idp/
  3. Tạo khoá riêng tư bằng cụm mật khẩu:
    sudo openssl genrsa -out server.key 2048
  4. Xoá cụm mật khẩu khỏi khoá:
    sudo openssl rsa -in server.key -out server.key
  5. Tạo yêu cầu ký chứng chỉ cho CA:
    sudo openssl req -x509 -sha256 -new -key server.key -out server.csr
  6. Tạo chứng chỉ tự ký có thời gian hết hạn là 365 ngày:
    sudo openssl x509 -sha256 -days 365 -in server.csr -signkey server.key -out selfsigned.crt
  7. Xuất khoá và chứng chỉ vào kho khoá:
    1. Xuất khoá và chứng chỉ sang kho khoá PKCS12:
    2. sudo openssl pkcs12 -export -clcerts -in <certificate_path> -inkey <key_path> -out <keystore_path> -name <alias>

      Các thông số:

      • certificate_path: Đường dẫn đến chứng chỉ được tạo ở Bước 6.
      • key_path: Đường dẫn đến khoá riêng tư được tạo ở Bước 3.
      • keystore_path: Đường dẫn đến kho khoá PKCS12 mới tạo chứa chứng chỉ và khoá riêng tư.
      • alias: Bí danh dùng để tham chiếu cặp khoá và chứng chỉ trong kho khoá.

      Hãy xem tài liệu về OpenSSL để biết thêm thông tin chi tiết.

    3. (Không bắt buộc) Xuất khoá và chứng chỉ từ PKCS12 sang kho khoá JKS:
    4. sudo keytool -importkeystore -srckeystore <PKCS12_keystore_path> -srcstoretype PKCS12 
      -destkeystore <destination_keystore_path> -deststoretype JKS -alias <alias>

      Các thông số:

      • PKCS12_keystore_path: Đường dẫn đến kho khoá PKCS12 được tạo ở Bước 7, chứa chứng chỉ và khoá riêng tư.
      • destination_keystore_path: Đường dẫn đến kho khoá JKS mới tạo chứa cùng một chứng chỉ và khoá.
      • alias: Bí danh dùng cho cặp khoá và chứng chỉ trong kho khoá JKS.

      Hãy xem tài liệu về keytool để biết thêm thông tin chi tiết.

    5. Thay đổi chủ sở hữu của tệp kho khoá đầu ra thành người dùng "apigee":
      sudo chown apigee:apigee <keystore_file>
    6. Cập nhật các thuộc tính sau trong 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

    Để bật TLS trên mô-đun SSO của Apigee, bằng cách đặt SSO_TOMCAT_PROFILE thành SSL_TERMINATION hoặc thành SSL_PROXY, bạn không thể sử dụng chứng chỉ tự ký. Bạn phải tạo một chứng chỉ từ một CA. Hãy xem phần Định cấu hình SSO Apigee để truy cập qua HTTPS để biết thêm thông tin.

    Chế độ cài đặt cấu hình SSO của Apigee

    Trước khi có thể cài đặt mô-đun SSO Apigee, bạn phải xác định một tệp cấu hình. Bạn truyền tệp cấu hình này đến trình cài đặt khi cài đặt mô-đun SSO Apigee.

    Tệp cấu hình có dạng như sau:

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

    Thuộc tính cấu hình SSO dựa trên SAML

    Nếu bạn đang sử dụng SAML cho IDP, hãy sử dụng khối thuộc tính cấu hình sau trong tệp cấu hình (được xác định ở trên):

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

    Thuộc tính cấu hình Liên kết trực tiếp LDAP

    Nếu bạn đang sử dụng tính năng liên kết trực tiếp LDAP cho IDP, hãy sử dụng khối thuộc tính cấu hình sau trong tệp cấu hình, như trong ví dụ trên:

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

    Thuộc tính cấu hình Liên kết gián tiếp LDAP

    Nếu bạn đang sử dụng tính năng liên kết gián tiếp LDAP cho IDP, hãy sử dụng khối thuộc tính cấu hình sau trong tệp cấu hình, như trong ví dụ trên:

    ## 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
    # Tên thuộc tính mà máy chủ LDAP sử dụng để tham chiếu đến địa chỉ email của người dùng; ví dụ: "mail" SSO_LDAP_MAIL_ATTRIBUTE=LDAP_email_attribute

    Cài đặt mô-đun SSO Apigee

    Sau khi tạo khoá và thiết lập tệp cấu hình, bạn có thể cài đặt mô-đun SSO của Apigee.

    Cách cài đặt mô-đun SSO Apigee:

    1. Đăng nhập vào nút Máy chủ quản lý. Nút đó phải đã cài đặt apigee-service, như mô tả trong phần Cài đặt tiện ích thiết lập apigee-setup của Edge.

      Ngoài ra, bạn có thể cài đặt mô-đun SSO Apigee trên một nút khác. Tuy nhiên, nút đó phải có thể truy cập vào Máy chủ quản lý qua cổng 8080.

    2. Cài đặt và định cấu hình apigee-sso bằng cách thực thi lệnh sau:
      /opt/apigee/apigee-setup/bin/setup.sh -p sso -f configFile

      Trong đó, configFile là tệp cấu hình mà bạn đã xác định ở trên.

    3. Cài đặt tiện ích apigee-ssoadminapi.sh dùng để quản lý người dùng máy và quản trị viên cho mô-đun apigee-sso:
      /opt/apigee/apigee-service/bin/apigee-service apigee-ssoadminapi install
    4. Đăng xuất khỏi shell, sau đó đăng nhập lại để thêm tiện ích apigee-ssoadminapi.sh vào đường dẫn.

    Chỉ định tệp siêu dữ liệu thay vì URL

    Nếu IDP của bạn không hỗ trợ URL siêu dữ liệu HTTP/HTTPS, bạn có thể sử dụng tệp XML siêu dữ liệu để định cấu hình Apigee SSO.

    Cách sử dụng tệp siêu dữ liệu thay vì URL để định cấu hình SSO Apigee:

    1. Sao chép nội dung của tệp siêu dữ liệu XML từ IDP vào một tệp trên nút SSO Apigee. Ví dụ: sao chép tệp XML vào:
      /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    2. Thay đổi quyền sở hữu tệp XML thành người dùng "apigee":
      chown apigee:apigee /opt/apigee/customer/application/apigee-sso/saml/metadata.xml
    3. Đặt giá trị của SSO_SAML_IDP_METADATA_URL thành đường dẫn tệp tuyệt đối:
      SSO_SAML_IDP_METADATA_URL=file:///opt/apigee/customer/application/apigee-sso/saml/metadata.xml

      Bạn phải thêm tiền tố "file://" vào đường dẫn tệp, theo sau là đường dẫn tuyệt đối từ thư mục gốc (/).