# Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: wso2am-p4-am-km-conf
  namespace : wso2-system
data:
  deployment.toml: |-
    [server]
    hostname = "wso2-km"
    node_ip = "$env{NODE_IP}"
    server_role = "api-key-manager"

    [user_store]
    type = "database_unique_id"

    [super_admin]
    username = "admin"
    password = "admin"
    create_admin_account = true

    [database.apim_db]
    type = "mysql"
    url = "jdbc:mysql://mysql-svc:3306/WSO2AM_APIMGT_DB?useSSL=false&amp;autoReconnect=true&amp;requireSSL=false&amp;verifyServerCertificate=false"
    username = "wso2carbon"
    password = "wso2carbon"
    driver = "com.mysql.cj.jdbc.Driver"

    [database.shared_db]
    type = "mysql"
    url = "jdbc:mysql://mysql-svc:3306/WSO2AM_SHARED_DB?useSSL=false&amp;autoReconnect=true&amp;requireSSL=false&amp;verifyServerCertificate=false"
    username = "wso2carbon"
    password = "wso2carbon"
    driver = "com.mysql.cj.jdbc.Driver"

    [keystore.tls]
    file_name =  "wso2carbon.jks"
    type =  "JKS"
    password =  "wso2carbon"
    alias =  "wso2carbon"
    key_password =  "wso2carbon"

    [truststore]
    file_name = "client-truststore.jks"
    type = "JKS"
    password = "wso2carbon"

    [[event_handler]]
    name="userPostSelfRegistration"
    subscriptions=["POST_ADD_USER"]

    [[event_listener]]
    id = "token_revocation"
    type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
    name = "org.wso2.is.notification.ApimOauthEventInterceptor"
    order = 1
    [event_listener.properties]
    notification_endpoint = "https://localhost:${mgt.transport.https.port}/internal/data/v1/notify"
    username = "${admin.username}"
    password = "${admin.password}"
    'header.X-WSO2-KEY-MANAGER' = "default"

    [apim.throttling]
    username= "$ref{super_admin.username}"
    password= "$ref{super_admin.password}"
    throttle_decision_endpoints = ["tcp://wso2-am-1-svc:5672","tcp://wso2-am-2-svc:5672"]

    [[apim.throttling.url_group]]
    traffic_manager_urls = ["tcp://wso2-am-1-svc:9611"]
    traffic_manager_auth_urls = ["ssl://wso2-am-1-svc:9711"]
    type = "loadbalance"

    [[apim.throttling.url_group]]
    traffic_manager_urls = ["tcp://wso2-am-2-svc:9611"]
    traffic_manager_auth_urls = ["ssl://wso2-am-2-svc:9711"]
    type = "loadbalance"

    [apim.event_hub]
    service_url = "https://wso2-am-svc:9443"
    event_listening_endpoints = ["tcp://wso2-am-1-svc:5672","tcp://wso2-am-2-svc:5672"]

    [[apim.event_hub.publish.url_group]]
    urls = ["tcp://wso2-am-1-svc:9611"]
    auth_urls = ["ssl://wso2-am-1-svc:9711"]

    [[apim.event_hub.publish.url_group]]
    urls = ["tcp://wso2-am-2-svc:9611"]
    auth_urls = ["ssl://wso2-am-2-svc:9711"]
