19.5.3. Manager での Apache の設定

  1. Manager で Apache を設定します。

    # yum install mod_auth_openidc
  2. /etc/httpd/conf.d に、以下の内容で新しい httpd 設定ファイル ovirt-openidc.conf を作成します。

    LoadModule auth_openidc_module modules/mod_auth_openidc.so
    
    OIDCProviderMetadataURL https://SSO.example.com/auth/realms/master/.well-known/openid-configuration
    OIDCSSLValidateServer Off
    
    OIDCClientID ovirt-engine
    OIDCClientSecret <client_SSO _generated_key>
    OIDCRedirectURI https://rhvm.example.com/ovirt-engine/callback
    OIDCDefaultURL https://rhvm.example.com/ovirt-engine/login?scope=ovirt-app-admin+ovirt-app-portal+ovirt-ext%3Dauth%3Asequence-priority%3D%7E
    
    # maps the prefered_username claim to the REMOTE_USER environment variable:
    
    OIDCRemoteUserClaim <preferred_username>
    OIDCCryptoPassphrase <random1234>
    
    <LocationMatch ^/ovirt-engine/sso/(interactive-login-negotiate|oauth/token-http-auth)|^/ovirt-engine/callback>
        <If "req('Authorization') !~ /^(Bearer|Basic)/i">
    
          Require valid-user
          AuthType openid-connect
    
          ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0; url=/ovirt-engine/sso/login-unauthorized\"/><body><a href=\"/ovirt-engine/sso/login-unauthorized\">Here</a></body></html>"
        </If>
    </LocationMatch>
    
    OIDCOAuthIntrospectionEndpoint https://SSO.example.com/auth/realms/master/protocol/openid-connect/token/introspect
    OIDCOAuthSSLValidateServer    Off
    OIDCOAuthIntrospectionEndpointParams token_type_hint=access_token
    OIDCOAuthClientID ovirt-engine
    OIDCOAuthClientSecret <client_SSO _generated_key>
    OIDCOAuthRemoteUserClaim sub
    
    <LocationMatch ^/ovirt-engine/(api$|api/)>
       AuthType oauth20
       Require valid-user
    </LocationMatch>
  3. 設定変更を保存するには、httpd および ovirt-engine を再起動します。

    # systemctl restart httpd
    # systemctl restart ovirt-engine
  4. 以下の内容で、/etc/ovirt-engine/extensions.d/openidc-authn.properties ファイルを作成します。

    ovirt.engine.extension.name = openidc-authn
    ovirt.engine.extension.bindings.method = jbossmodule
    ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.misc
    ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.misc.http.AuthnExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authn
    ovirt.engine.aaa.authn.profile.name = openidchttp
    ovirt.engine.aaa.authn.authz.plugin = openidc-authz
    ovirt.engine.aaa.authn.mapping.plugin = openidc-http-mapping
    config.artifact.name = HEADER
    config.artifact.arg = OIDC_CLAIM_preferred_username
  5. 以下の内容で、/etc/ovirt-engine/extensions.d/openidc-http-mapping.properties ファイルを作成します。

    ovirt.engine.extension.name = openidc-http-mapping
    ovirt.engine.extension.bindings.method = jbossmodule
    ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.misc
    ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.misc.mapping.MappingExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Mapping
    config.mapAuthRecord.type = regex
    config.mapAuthRecord.regex.mustMatch = false
    config.mapAuthRecord.regex.pattern = ^(?<user>.*?)((\\\\(?<at>@)(?<suffix>.*?)@.*)|(?<realm>@.*))$
    config.mapAuthRecord.regex.replacement = ${user}${at}${suffix}
  6. 以下の内容で、/etc/ovirt-engine/extensions.d/openidc-authz.properties ファイルを作成します。

    ovirt.engine.extension.name = openidc-authz
    ovirt.engine.extension.bindings.method = jbossmodule
    ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.misc
    ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.misc.http.AuthzExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authz
    config.artifact.name.arg = OIDC_CLAIM_preferred_username
    config.artifact.groups.arg = OIDC_CLAIM_groups
  7. 以下の内容で、/etc/ovirt-engine/engine.conf.d/99-enable-external-auth.conf ファイルを作成します。

    ENGINE_SSO_ENABLE_EXTERNAL_SSO=true
    ENGINE_SSO_EXTERNAL_SSO_LOGOUT_URI="${ENGINE_URI}/callback"
    EXTERNAL_OIDC_USER_INFO_END_POINT=https://SSO.example.com/auth/realms/master/protocol/openid-connect/userinfo
    EXTERNAL_OIDC_TOKEN_END_POINT=https://SSO.example.com/auth/realms/master/protocol/openid-connect/token
    EXTERNAL_OIDC_LOGOUT_END_POINT=https://SSO.example.com/auth/realms/master/protocol/openid-connect/logout
    EXTERNAL_OIDC_CLIENT_ID=ovirt-engine
    EXTERNAL_OIDC_CLIENT_SECRET="<client_SSO _generated_key>"
    EXTERNAL_OIDC_HTTPS_PKI_TRUST_STORE="/etc/pki/java/cacerts"
    EXTERNAL_OIDC_HTTPS_PKI_TRUST_STORE_PASSWORD=""
    EXTERNAL_OIDC_SSL_VERIFY_CHAIN=false
    EXTERNAL_OIDC_SSL_VERIFY_HOST=false