ติดตั้งและกําหนดค่า SSO ของ Apigee

หากต้องการติดตั้งและกําหนดค่าโมดูล SSO ของ Apigee ด้วย IDP ภายนอก คุณต้องทําดังนี้

  1. สร้างคีย์และใบรับรอง
  2. ตั้งค่าการกําหนดค่า SSO พื้นฐานของ Apigee: ไฟล์ฐานต้องมีพร็อพเพอร์ตี้ที่ใช้ร่วมกันในการกําหนดค่า SSO ทั้งหมด
  3. เพิ่มพร็อพเพอร์ตี้การกําหนดค่าเฉพาะ IdP: ใช้บล็อกพร็อพเพอร์ตี้การกําหนดค่าเฉพาะ IdP รายการใดรายการหนึ่งต่อไปนี้ในไฟล์การกําหนดค่า
  4. ติดตั้ง Apigee SSO: ติดตั้งโมดูล Apigee SSO แล้วส่งไฟล์การกําหนดค่าไปยังโปรแกรมติดตั้ง

อ่านข้อมูลเกี่ยวกับแต่ละขั้นตอนเหล่านี้ได้ในส่วนต่อไปนี้

สร้างคีย์และใบรับรอง

ส่วนนี้จะอธิบายวิธีสร้างใบรับรองที่ลงนามด้วยตนเอง ซึ่งอาจใช้ได้กับสภาพแวดล้อมการทดสอบ แต่คุณควรใช้ใบรับรองที่ลงนามโดย Certificate Authority (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: เส้นทางไปยังคีย์สโตร์ PKCS12 ที่สร้างขึ้นในขั้นตอนที่ 7 ซึ่งมีใบรับรองและคีย์ส่วนตัว
      • 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

    หากต้องการเปิดใช้ TLS ในโมดูล SSO ของ Apigee โดยการตั้งค่า SSO_TOMCAT_PROFILE เป็น SSL_TERMINATION หรือ SSL_PROXY คุณจะใช้ใบรับรองที่ลงนามด้วยตนเองไม่ได้ คุณต้องสร้างใบรับรองจาก CA ดูข้อมูลเพิ่มเติมได้ที่กำหนดค่า SSO ของ Apigee สำหรับการเข้าถึง HTTPS

    การตั้งค่าการกําหนดค่า SSO ของ Apigee

    คุณต้องกำหนดไฟล์การกําหนดค่าก่อนจึงจะติดตั้งโมดูล SSO ของ Apigee ได้ คุณส่งไฟล์การกำหนดค่านี้ไปยังโปรแกรมติดตั้งเมื่อติดตั้งโมดูล SSO ของ Apigee

    ไฟล์การกําหนดค่ามีรูปแบบดังนี้

    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

    หากคุณใช้ SAML สำหรับ IdP ให้ใช้บล็อกพร็อพเพอร์ตี้การกําหนดค่าต่อไปนี้ในไฟล์การกําหนดค่า (ที่ระบุไว้ด้านบน)

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

    หากคุณใช้การเชื่อมโยงโดยตรงของ LDAP สำหรับ IdP ให้ใช้บล็อกพร็อพเพอร์ตี้การกําหนดค่าต่อไปนี้ในไฟล์การกําหนดค่า ดังที่แสดงในตัวอย่างด้านบน

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

    หากคุณใช้การเชื่อมโยงโดยอ้อม LDAP สำหรับ IdP ให้ใช้บล็อกพร็อพเพอร์ตี้การกําหนดค่าต่อไปนี้ในไฟล์การกําหนดค่า ดังที่แสดงในตัวอย่างด้านบน

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

    ติดตั้งโมดูล SSO ของ Apigee

    หลังจากสร้างคีย์และตั้งค่าไฟล์การกําหนดค่าแล้ว คุณจะติดตั้งโมดูล SSO ของ Apigee ได้

    วิธีติดตั้งโมดูล SSO ของ Apigee

    1. เข้าสู่ระบบโหนดเซิร์ฟเวอร์การจัดการ โหนดดังกล่าวควรมีapigee-serviceติดตั้งอยู่แล้วตามที่อธิบายไว้ในติดตั้งยูทิลิตี apigee-setup ของ Edge

      หรือสามารถติดตั้งโมดูล SSO ของ Apigee ในโหนดอื่น อย่างไรก็ตาม โหนดดังกล่าวต้องเข้าถึงเซิร์ฟเวอร์การจัดการผ่านพอร์ต 8080 ได้

    2. ติดตั้งและกำหนดค่า apigee-sso โดยเรียกใช้คำสั่งต่อไปนี้
      /opt/apigee/apigee-setup/bin/setup.sh -p sso -f configFile

      โดยที่ configFile คือไฟล์การกําหนดค่าที่คุณกําหนดไว้ด้านบน

    3. ติดตั้งยูทิลิตี apigee-ssoadminapi.sh ที่ใช้จัดการผู้ดูแลระบบและผู้ใช้เครื่องสำหรับโมดูล apigee-sso
      /opt/apigee/apigee-service/bin/apigee-service apigee-ssoadminapi install
    4. ออกจากระบบเชลล์แล้วลงชื่อเข้าใช้อีกครั้งเพื่อเพิ่มยูทิลิตี apigee-ssoadminapi.sh ลงในเส้นทาง

    ระบุไฟล์ข้อมูลเมตาแทน URL

    หาก IdP ไม่รองรับ URL ข้อมูลเมตา HTTP/HTTPS คุณสามารถใช้ไฟล์ XML ข้อมูลเมตาเพื่อกําหนดค่า SSO ของ Apigee ได้

    หากต้องการใช้ไฟล์ข้อมูลเมตาแทน URL เพื่อกำหนดค่า SSO ของ Apigee ให้ทำดังนี้

    1. คัดลอกเนื้อหาของ XML ข้อมูลเมตาจาก IDP ไปยังไฟล์บนโหนด SSO ของ Apigee เช่น คัดลอก 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://" ต่อหน้าเส้นทางไฟล์ ตามด้วยเส้นทางสัมบูรณ์จากรูท (/)