We installed the APMs according to the document.
https://apim.docs.wso2.com/en/latest/install-and-setup/setup/distributed-deployment/deploying-wso2-api-m-in-a-distributed-setup-with-km-separated/
But when we define a throttling policy in the admin panel, the policy is not published and Not applied for request.
APIM version is 4.0.0
[GW Configuration]
[apim.throttling]
username= "$ref{super_admin.username}"
password= "$ref{super_admin.password}"
service_url = "https://amtm.dev:9443/services/"
throttle_decision_endpoints = ["tcp://amtml01.dev:5672" , "tcp://amtml02.dev:5672"]
enable_query_param_based_throttling = true
enable_jwt_claim_based_throttling = true
enable_header_based_throttling= true
enable_blacklist_condition = true
enable_policy_deploy=true
enable_data_publishing=true
[[apim.throttling.url_group]]
traffic_manager_urls=["tcp://amtml01.dev:9611"]
traffic_manager_auth_urls=["ssl://amtml01.dev:9711"]
traffic_manager_username="admin"
traffic_manager_password="admin"
[[apim.throttling.url_group]]
traffic_manager_urls=["tcp://amtml02.dev:9611"]
traffic_manager_auth_urls=["ssl://amtml02.dev:9711"]
traffic_manager_username="admin"
traffic_manager_password="admin"
[[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://amcp.dev:${mgt.transport.https.port}/internal/data/v1/notify"
username = "${admin.username}"
password = "${admin.password}"
'header.X-WSO2-KEY-MANAGER' = "default"
[apim.event_hub]
enabled = true
service_url = "https://amcp.dev:9443/services/"
username="admin"
password="admin"
event_listening_endpoints=["tcp://amcpl01.dev:5672" , "tcp://amcpl02.dev:5672"]
#environmentLabels = ["Default"]
#retryInterval = 5
#skipSSLVerification=true
[[apim.event_hub.publish.url_group]]
urls=["tcp://amcpl01.dev:9611"]
auth_urls=["ssl://amcpl01.dev:9711"]
username="admin"
password="admin"
[[apim.event_hub.publish.url_group]]
urls=["tcp://amcpl02.dev:9611"]
auth_urls=["ssl://amcpl02.dev:9711"]
username="admin"
password="admin"
[CP Configuration]
[apim.throttling]
service_url = "https://amtm.dev:9443/services/"
event_duplicate_url = ["tcp://amcpl02.dev:5672"]
username = "$ref{super_admin.username}"
password = "$ref{super_admin.password}"
enable_data_publishing = true
enable_query_param_based_throttling = true
enable_jwt_claim_based_throttling = true
enable_header_based_throttling= true
enable_blacklist_condition = true
[[apim.throttling.url_group]]
traffic_manager_urls = ["tcp://amtm01.dev:9611"]
traffic_manager_auth_urls = ["ssl://amtm01.dev:9711"]
[[apim.throttling.url_group]]
traffic_manager_urls = ["tcp://amtm02.dev:9611"]
traffic_manager_auth_urls = ["ssl://amtm02.dev:9711"]
[[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://amcp.dev:9443/internal/data/v1/notify"
username = "${admin.username}"
password = "${admin.password}"
'header.X-WSO2-KEY-MANAGER' = "default"
[apim.event_hub]
enable = true
username = "$ref{super_admin.username}"
password = "$ref{super_admin.password}"
service_url = "https://amcpl01.dev:9443/services/"
event_listening_endpoints = ["tcp://amcpl01.dev:5672"]
[[apim.event_hub.publish.url_group]]
urls = ["tcp://amcpl01.dev:9611"]
auth_urls = ["ssl://amcpl01.dev:9711"]
[[apim.event_hub.publish.url_group]]
urls = ["tcp://amcpl02.dev:9611"]
auth_urls = ["ssl://amcpl02.dev:9711"]
[TM Configuration]
[apim.throttling]
username= "$ref{super_admin.username}"
password= "$ref{super_admin.password}"
service_url = "https://amtm.dev:9443/services/"
throttle_decision_endpoints = ["tcp://amtml01.dev:5672"]
enable_query_param_based_throttling = true
event_duplicate_url = ["tcp://amtml02.dev:5672"]
enable_jwt_claim_based_throttling = true
enable_header_based_throttling= true
enable_blacklist_condition = true
[[apim.throttling.url_group]]
traffic_manager_urls=["tcp://amtml01.dev:9611"]
traffic_manager_auth_urls=["ssl://amtml01.dev:9711"]
traffic_manager_username="admin"
traffic_manager_password="admin"
[[apim.throttling.url_group]]
traffic_manager_urls=["tcp://amtml02.dev:9611"]
traffic_manager_auth_urls=["ssl://amtml02.dev:9711"]
traffic_manager_username="admin"
traffic_manager_password="admin"
[apim.event_hub]
enable = true
username = "$ref{super_admin.username}"
password = "$ref{super_admin.password}"
service_url = "https://amcp.dev:9443/services/"
event_listening_endpoints = ["tcp://amcp01.dev:5672","tcp://amcp02.dev:5672"]
[[apim.event_hub.publish.url_group]]
urls = ["tcp://amcp01.dev:9611"]
auth_urls = ["ssl://amcp01.dev:9711"]
[[apim.event_hub.publish.url_group]]
urls = ["tcp://amcp02.dev:9611"]
auth_urls = ["ssl://amcp02.dev:9711"]
What could be the problem?
Related
I migrated WSO2 AM from 3.0.0 to 4.0.0 by following the wso2 docs. The migration was successful, however after migration I'm unable to call the APIs. I use Postman for the same.
I have a single node linux(VM-Amazon linux) setup, using Mysql(Amazon RDS) as my db.
I deployed a sample API that's provided by WSO2. When I call the API, I get a 404 in postman.
This is what I get in the carbon logs:
INFO {org.apache.synapse.mediators.builtin.LogMediator} - STATUS = Message dispatched to the main sequence. Invalid URL., RESOURCE = /pizzashack/1.0.0/menu, HEALTH CHECK URL = /pizzashack/1.0.0/menu
The attached snippet is the postman response.
{"code":"404","type":"Status report","message":"Not Found","description":"The requested resource is not available."}
#Athiththan below is the TOML configuration for 4.0.0
Sorry for the poor formatting though.
[server]
hostname = "<hostname>"
#offset=0
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"
[super_admin]
username = "<username>"
password = "<password>"
create_admin_account = true
[user_store]
type = "database"
[database.apim_db]
type = "mysql"
url = "jdbc:mysql://<mysql_here>:3306/apim_db?autoReconnect=true&useSSL=false"
username = "<user>"
password = "<password>"
[database.shared_db]
type = "mysql"
url = "jdbc:mysql://<mysql_here>:3306/shared_db?autoReconnect=true&useSSL=false"
username = "<username>"
password = "<password>"
[keystore.tls]
file_name = "wso2carbon.jks"
type = "JKS"
password = "<password>"
alias = "<alias>"
key_password = "<password>"
#[keystore.primary]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
#[keystore.internal]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
#[keystore.internal]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url = "https://localhost:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"
ws_endpoint = "ws://localhost:9099"
wss_endpoint = "wss://localhost:8099"
http_endpoint = "http://localhost:${http.nio.port}"
https_endpoint = "https://localhost:${https.nio.port}"
websub_event_receiver_http_endpoint = "http://localhost:9021"
websub_event_receiver_https_endpoint = "https://localhost:8021"
[apim.sync_runtime_artifacts.gateway]
gateway_labels =["Default"]
#[apim.cache.gateway_token]
#enable = true
#expiry_time = "900s"
#[apim.cache.resource]
#enable = true
#expiry_time = "900s"
#[apim.cache.km_token]
#enable = false
#expiry_time = "15m"
#[apim.cache.recent_apis]
#enable = false
#[apim.cache.scopes]
#enable = true
#[apim.cache.publisher_roles]
#enable = true
#[apim.cache.jwt_claim]
#enable = true
#expiry_time = "15m"
#[apim.cache.tags]
#expiry_time = "2m"
[apim.analytics]
enable = false
config_endpoint = "https://localhost:8080/auth/v1"
auth_token = ""
#[apim.key_manager]
#service_url = "https://localhost:${mgt.transport.https.port}/services/"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#pool.init_idle_capacity = 50
#pool.max_idle = 100
#key_validation_handler_type = "default"
#key_validation_handler_type = "custom"
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler"
#[apim.idp]
#server_url = "https://localhost:${mgt.transport.https.port}"
#authorize_endpoint = "https://localhost:${mgt.transport.https.port}/oauth2/authorize"
#oidc_logout_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/logout"
#oidc_check_session_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/checksession"
#[apim.jwt]
#enable = true
#encoding = "base64" # base64,base64url
#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
#claim_dialect = "http://wso2.org/claims"
#convert_dialect = false
#header = "X-JWT-Assertion"
#signing_algorithm = "SHA256withRSA"
#enable_user_claims = true
#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.ExtendedDefaultClaimsRetriever"
#[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
#revoke_endpoint = "https://localhost:${https.nio.port}/revoke"
#enable_token_encryption = false
#enable_token_hashing = false
#[apim.devportal]
#url = "https://localhost:${mgt.transport.https.port}/devportal"
#enable_application_sharing = false
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl"
#display_multiple_versions = false
#display_deprecated_apis = false
#enable_comments = true
#enable_ratings = true
#enable_forum = true
#enable_anonymous_mode=true
#enable_cross_tenant_subscriptions = true
#default_reserved_username = "apim_reserved_user"
[apim.cors]
allow_origins = "*"
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey","Internal-Key"]
allow_credentials = false
#[apim.throttling]
#enable_data_publishing = true
#enable_policy_deploy = true
#enable_blacklist_condition = true
#enable_persistence = true
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"]
#[apim.throttling.blacklist_condition]
#start_delay = "5m"
#period = "1h"
#[apim.throttling.jms]
#start_delay = "5m"
#[apim.throttling.event_sync]
#hostName = "0.0.0.0"
#port = 11224
#[apim.throttling.event_management]
#hostName = "0.0.0.0"
#port = 10005
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "loadbalance"
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "failover"
#[apim.workflow]
#enable = false
#service_url = "https://localhost:9445/bpmn"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/admin/v0.17/workflows/update-workflow-status"
#token_endpoint = "https://localhost:${https.nio.port}/token"
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register"
#client_registration_username = "$ref{super_admin.username}"
#client_registration_password = "$ref{super_admin.password}"
#data bridge config
#[transport.receiver]
#type = "binary"
#worker_threads = 10
#session_timeout = "30m"
#keystore.file_name = "$ref{keystore.tls.file_name}"
#keystore.password = "$ref{keystore.tls.password}"
#tcp_port = 9611
#ssl_port = 9711
#ssl_receiver_thread_pool_size = 100
#tcp_receiver_thread_pool_size = 100
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"]
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"]
#[apim.notification]
#from_address = "APIM.com"
#username = "APIM"
#password = "APIM+123"
#hostname = "localhost"
#port = 3025
#enable_start_tls = false
#enable_authentication = true
#[apim.token.revocation]
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl"
#enable_realtime_notifier = true
#realtime_notifier.ttl = 5000
#enable_persistent_notifier = true
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/"
#persistent_notifier.ttl = 5000
#persistent_notifier.username = "root"
#persistent_notifier.password = "root"
[[event_handler]]
name="userPostSelfRegistration"
subscriptions=["POST_ADD_USER"]
[service_provider]
sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"
[database.local]
url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"
[[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"
[encryption]
key = "<key_here>"
[transport.https.properties]
proxyPort = 443
Below is the TOML config for 3.0.0
[server]
hostname = "<hostname_here>"
node_ip = "127.0.0.1"
#offset=0
mode = "single" #single or ha
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"
[super_admin]
username = "<username>"
password = "<password>"
create_admin_account = true
[user_store]
type = "database"
[database.apim_db]
type = "mysql"
url = "jdbc:mysql://<mysql_here>:3306/apim_db?autoReconnect=true&useSSL=false"
username = "<username>"
password = "<password>"
[database.shared_db]
type = "mysql"
url = "jdbc:mysql://<mysql_here>:3306/shared_db?autoReconnect=true&useSSL=false"
username = "<username>"
password = "<password>"
[keystore.tls]
file_name = "wso2carbon.jks"
type = "JKS"
password = "<password>"
alias = "<alias>"
key_password = "<password>"
[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url = "https://localhost:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"
ws_endpoint = "ws://localhost:9099"
wss_endpoint = "wss://localhost:8099"
http_endpoint = "http://localhost:${http.nio.port}"
https_endpoint = "https://localhost:${https.nio.port}"
#[apim.cache.gateway_token]
#enable = true
#expiry_time = "900s"
#[apim.cache.resource]
#enable = true
#expiry_time = "900s"
#[apim.cache.km_token]
#enable = false
#expiry_time = "15m"
#[apim.cache.recent_apis]
#enable = false
#[apim.cache.scopes]
#enable = true
#[apim.cache.publisher_roles]
#enable = true
#[apim.cache.jwt_claim]
#enable = true
#expiry_time = "15m"
#[apim.cache.tags]
#expiry_time = "2m"
#[apim.analytics]
#enable = false
#store_api_url = "https://localhost:7444"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#event_publisher_type = "default"
#event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher"
#publish_response_size = true
#[[apim.analytics.url_group]]
#analytics_url =["tcp://analytics1:7611","tcp://analytics2:7611"]
#analytics_auth_url =["ssl://analytics1:7711","ssl://analytics2:7711"]
#type = "loadbalance"
#[[apim.analytics.url_group]]
#analytics_url =["tcp://analytics1:7612","tcp://analytics2:7612"]
#analytics_auth_url =["ssl://analytics1:7712","ssl://analytics2:7712"]
#type = "failover"
#[apim.key_manager]
#service_url = "https://localhost:${mgt.transport.https.port}/services/"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#pool.init_idle_capacity = 50
#pool.max_idle = 100
#key_validation_handler_type = "default"
#key_validation_handler_type = "custom"
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler"
#[apim.jwt]
#enable = true
#encoding = "base64" # base64,base64url
#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
#claim_dialect = "http://wso2.org/claims"
#header = "X-JWT-Assertion"
#signing_algorithm = "SHA256withRSA"
#enable_user_claims = true
#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever"
#[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
#revoke_endpoint = "https://localhost:${https.nio.port}/revoke"
#enable_token_encryption = false
#enable_token_hashing = false
#[apim.devportal]
#url = "https://localhost:${mgt.transport.https.port}/devportal"
#enable_application_sharing = false
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl"
#display_multiple_versions = false
#display_deprecated_apis = false
#enable_comments = true
#enable_ratings = true
#enable_forum = true
[apim.cors]
allow_origins = "*"
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction"]
allow_credentials = false
#[apim.throttling]
#enable_data_publishing = true
#enable_policy_deploy = true
#enable_blacklist_condition = true
#enable_persistence = true
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"]
#[apim.throttling.blacklist_condition]
#start_delay = "5m"
#period = "1h"
#[apim.throttling.jms]
#start_delay = "5m"
#[apim.throttling.event_sync]
#hostName = "0.0.0.0"
#port = 11224
#[apim.throttling.event_management]
#hostName = "0.0.0.0"
#port = 10005
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "loadbalance"
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "failover"
#[apim.workflow]
#enable = false
#service_url = "https://localhost:9445/bpmn"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/admin/v0.15/workflows/update-workflow-status"
#token_endpoint = "https://localhost:${https.nio.port}/token"
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.15/register"
#client_registration_username = "$ref{super_admin.username}"
#client_registration_password = "$ref{super_admin.password}"
#data bridge config
#[transport.receiver]
#type = "binary"
#worker_threads = 10
#session_timeout = "30m"
#keystore.file_name = "$ref{keystore.tls.file_name}"
#keystore.password = "$ref{keystore.tls.password}"
#tcp_port = 9611
#ssl_port = 9711
#ssl_receiver_thread_pool_size = 100
#tcp_receiver_thread_pool_size = 100
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"]
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"]
#[apim.notification]
#from_address = "APIM.com"
#username = "APIM"
#password = "APIM+123"
#hostname = "localhost"
#port = 3025
#enable_start_tls = false
#enable_authentication = true
#[apim.token.revocation]
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl"
#enable_realtime_notifier = true
#realtime_notifier.ttl = 5000
#enable_persistent_notifier = true
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/"
#persistent_notifier.ttl = 5000
#persistent_notifier.username = "root"
#persistent_notifier.password = "root"
[[event_handler]]
name="userPostSelfRegistration"
subscriptions=["POST_ADD_USER"]
[service_provider]
sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"
[transport.https.properties]
proxyPort = 443
[[apim.throttling.url_group]]
traffic_manager_urls = ["tcp://<IP>:9611"]
traffic_manager_auth_urls = ["ssl://<IP>:9711"]
type = "loadbalance"
[passthru_http]
http.connection.timeout = 300000
http.socket.timeout = 300000
[synapse_properties]
synapse.global_timeout_interval = 300000
Can you please check for any mis-configuration.
The following error can be observed when the Synapse Artifact of the mentioned API is not available in the API Manager Gateway.
{"code":"404","type":"Status report","message":"Not Found","description":"The requested resource is not available."}
You are able to see the APIs in both Publisher Portal and Devportal as they are fetched from Databases. However, for API invocation, the API Manager Gateway needs the API definition deployed as Synapse Artifact.
Try re-publishing the API from the Publisher portal to deploy the required Synapse Artifacts in the API Manager Gateway node | Deploy a new revision
Go to the Publisher portal
Open the respective API
Navigate to Deploy > Deployments
Click on Deploy New Revision and select the appropriate Gateway Environments and Deploy
This will create a new revision of the API and notifies the Gateway environments to fetch and deploy the Synapse Artifacts for API invocation.
Regarding TOML Configurations
Update the gateway_labels configuration in API Manager 4.0.0 as following
[apim.sync_runtime_artifacts.gateway]
gateway_labels =["Production and Sandbox"]
The gateway_labels should match the values of the Gateway Environment names. Since you have configured a Gateway Environment with the name "Production and Sandbox", the gateway_labels configuration needs to be updated as mentioned above.
Update the configurations, restart the API Manager server, and republish the APIs and try-out the scenario.
I newly installed an instance of WSO2 API Manager 4.0.0 using the Simple Node configuration https://apim.docs.wso2.com/en/latest/install-and-setup/setup/single-node/configuring-a-single-node/ on a virtual machine.
I can create my APIs (with internal existing API, or pizzashack sample) in the WSO2 publisher. But when I try to call the API, using the try out menu, I have a simple 'TypeError: NetworkError when attempting to fetch resource.'
In the firefox browser console I have a 'CORS Missing Allow Origin' error on an OPTIONS call to the API manager.
For this issue I've applied https://apim.docs.wso2.com/en/latest/design/advanced-topics/enabling-cors-for-apis/ but with no success.
Here's my deployment.toml file with the customization I made.
[server]
hostname = "apim-p.<redacted dns>.com"
#offset=0
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"
[super_admin]
username = "<redacted username>"
password = "<redacted password>"
create_admin_account = true
[user_store]
type = "database_unique_id"
[database.apim_db]
type = "postgre"
url = "jdbc:postgresql://<redacted IP>:5432/wso2_apim"
username = "wso2"
password = "<redacted password>"
pool_options.maxActive = 10
[database.shared_db]
type = "postgre"
url = "jdbc:postgresql://<redacted IP>:5432/wso2_shared"
username = "wso2"
password = "<redacted password>"
pool_options.maxActive = 50
[keystore.tls]
file_name = "apim.<redacted dns>.com.jks"
type = "JKS"
password = "<redacted password>"
alias = "apim-p.<redacted dns>"
key_password = "<redacted password>"
#[keystore.primary]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
#[keystore.internal]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
[[apim.gateway.environment]]
name = "Production"
type = "production"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"
ws_endpoint = "ws://apim-p.<redacted dns>.com:9099"
wss_endpoint = "wss://apim-p.<redacted dns>.com:8099"
http_endpoint = "http://apim-p.<redacted dns>.com:${http.nio.port}"
https_endpoint = "https://apim-p.<redacted dns>.com:${https.nio.port}"
websub_event_receiver_http_endpoint = "http://apim-p.<redacted dns>.com:9021"
websub_event_receiver_https_endpoint = "https://apim-p.<redacted dns>.com:8021"
[apim.sync_runtime_artifacts.gateway]
gateway_labels =["Default"]
#[apim.cache.gateway_token]
#enable = true
#expiry_time = "900s"
#[apim.cache.resource]
#enable = true
#expiry_time = "900s"
#[apim.cache.km_token]
#enable = false
#expiry_time = "15m"
#[apim.cache.recent_apis]
#enable = false
#[apim.cache.scopes]
#enable = true
#[apim.cache.publisher_roles]
#enable = true
#[apim.cache.jwt_claim]
#enable = true
#expiry_time = "15m"
#[apim.cache.tags]
#expiry_time = "2m"
[apim.analytics]
enable = false
config_endpoint = "https://apim-p.<redacted dns>.com:8080/auth/v1"
auth_token = ""
#[apim.key_manager]
#service_url = "https://localhost:${mgt.transport.https.port}/services/"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#pool.init_idle_capacity = 50
#pool.max_idle = 100
#key_validation_handler_type = "default"
#key_validation_handler_type = "custom"
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler"
#[apim.idp]
#server_url = "https://localhost:${mgt.transport.https.port}"
#authorize_endpoint = "https://localhost:${mgt.transport.https.port}/oauth2/authorize"
#oidc_logout_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/logout"
#oidc_check_session_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/checksession"
#[apim.jwt]
#enable = true
#encoding = "base64" # base64,base64url
#generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
#claim_dialect = "http://wso2.org/claims"
#convert_dialect = false
#header = "X-JWT-Assertion"
#signing_algorithm = "SHA256withRSA"
#enable_user_claims = true
#claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.ExtendedDefaultClaimsRetriever"
#[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
#revoke_endpoint = "https://localhost:${https.nio.port}/revoke"
#enable_token_encryption = false
#enable_token_hashing = false
[apim.devportal]
url = "https://apim-p.<redacted dns>.com:${mgt.transport.https.port}/devportal"
#enable_application_sharing = false
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl"
#display_multiple_versions = false
#display_deprecated_apis = false
enable_comments = false
enable_ratings = false
enable_forum = false
enable_anonymous_mode=false
enable_cross_tenant_subscriptions = false
#default_reserved_username = "apim_reserved_user"
[apim.cors]
allow_origins = "*"
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey","Internal-Key"]
allow_credentials = false
#[apim.throttling]
#enable_data_publishing = true
#enable_policy_deploy = true
#enable_blacklist_condition = true
#enable_persistence = true
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"]
#[apim.throttling.blacklist_condition]
#start_delay = "5m"
#period = "1h"
#[apim.throttling.jms]
#start_delay = "5m"
#[apim.throttling.event_sync]
#hostName = "0.0.0.0"
#port = 11224
#[apim.throttling.event_management]
#hostName = "0.0.0.0"
#port = 10005
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "loadbalance"
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "failover"
#[apim.workflow]
#enable = false
#service_url = "https://localhost:9445/bpmn"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/admin/v0.17/workflows/update-workflow-status"
#token_endpoint = "https://localhost:${https.nio.port}/token"
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.17/register"
#client_registration_username = "$ref{super_admin.username}"
#client_registration_password = "$ref{super_admin.password}"
#data bridge config
#[transport.receiver]
#type = "binary"
#worker_threads = 10
#session_timeout = "30m"
#keystore.file_name = "$ref{keystore.tls.file_name}"
#keystore.password = "$ref{keystore.tls.password}"
#tcp_port = 9611
#ssl_port = 9711
#ssl_receiver_thread_pool_size = 100
#tcp_receiver_thread_pool_size = 100
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"]
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"]
[apim.notification]
from_address = "apim-p#<redacted dns>.com"
#username = "APIM"
#password = "APIM+123"
hostname = "smtp.<redacted dns>.com"
port = 25
#enable_start_tls = false
enable_authentication = false
signature = "API Manager PROD"
[output_adapter.email]
from_address = "apim-p#<redacted dns>.com"
hostname = "smtp.<redacted dns>.com"
port = 25
signature = "API Manager PROD"
enable_authentication = false
#[apim.token.revocation]
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl"
#enable_realtime_notifier = true
#realtime_notifier.ttl = 5000
#enable_persistent_notifier = true
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/"
#persistent_notifier.ttl = 5000
#persistent_notifier.username = "root"
#persistent_notifier.password = "root"
[[event_handler]]
name="userPostSelfRegistration"
subscriptions=["POST_ADD_USER"]
[service_provider]
sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"
[database.local]
url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"
[[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://apim-p.<redacted dns>.com:${mgt.transport.https.port}/internal/data/v1/notify"
username = "${admin.username}"
password = "${admin.password}"
'header.X-WSO2-KEY-MANAGER' = "default"
[identity_mgt.endpoint]
enable_self_signup_endpoint=false
I already spent several days looking for answers within stackoverflow, WSO2 official documentations and WSO2 github, but with no success.
Did I missed something somewhere ?
I was facing the same issue until this morning.
https://github.com/wso2/api-manager/issues/68
My context is a little bit different, i use a Docker active-active distributed deployment.
I think I played too much with the deployment.toml, because a remove and recreate container fix the problem.
I don't know if it can help but i added that :
[apim.sync_runtime_artifacts.gateway]
enable = true
gateway_labels =["Default"]
[apim.sync_runtime_artifacts.publisher]
artifact_saver = "DBSaver"
publish_directly_to_gateway = true
While configuring fresh installs of wso2 API-Manager and Identity server, we have encountered this issue. Identity providers added through the API UI will populate in the IS UI, but service providers added through the IS console do not appear on API.
The two servers are running on EC2 instances with all traffic opened between them and we have verified on a different installation that the certs and keystores being used should not be causing any problems. We have not seen any specific connection refused issues in the logs, either, and the tcpdump shows that the two servers are communicating back and forth with each other. Using the working installation as a reference, there also does not appear to be any discrepancies from the deployment.tomls.
Both EC2s share the same RDS postgres database, but what is interesting is that if you try to manually add the service provider in the API UI, it will say that a provider with the same name already exists (meaning that it is reaching out to the database and finding the providers created in IS but it's still not populating them in the list in API console).
We've really been stumped by this one so any help would be greatly appreciated. Even trace/debug logs have not been helpful, but just let me know of any screenshots that could aid in remedying this problem. Thank you.
Edits:
WSO2 AM is version 3.1.0, WSO2 IS is version 5.10.0.
Both shared_db and the am_dbs are shared across both instances
deployment.toml for IS
[server]
hostname =
node_ip = "127.0.0.1"
base_path = "https://$ref{server.hostname}:${carbon.management.port}"
serverDetails = "WSO2 IS as KM 5.10.0"
mode = "single"
userAgent = "WSO2 IS as KM 5.10.0"
[super_admin]
username =
password =
create_admin_account = true
[user_store]
type = "database_unique_id"
[user_store.properties]
IsEmailUserName = false
MaxRoleNameListLength = 101
SharedGroupEnabled = false
UsernameJavaRegEx = "[a-zA-Z0-9#._\\+-|//]{3,50}$"
UsernameJavaScriptRegEx = "^[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"
UsernameWithEmailJavaScriptRegEx = "[a-zA-Z0-9#._+-|//]{3,50}$"
UserRolesCacheEnabled = false
[database.apim_db]
type = "postgre"
url = "jdbc:postgresql://wso2_am?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.shared_db]
type = "postgre"
url = "jdbc:postgresql://wso2_shared?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.config]
type = "postgre"
url = "jdbc:postgresql://wso2_shared?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.user]
type = "postgre"
url = "jdbc:postgresql://wso2_user?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[realm_manager]
data_source = "WSO2USER_DB"
[database.apim_db.pool_options]
maxActive = "80"
maxWait = "60000"
minIdle = "5"
testOnBorrow = true
validationQuery="SELECT 1; COMMIT"
validationInterval="30000"
defaultAutoCommit=true
[database.shared_db.pool_options]
maxActive = "80"
maxWait = "60000"
minIdle = "5"
testOnBorrow = true
validationQuery="SELECT 1; COMMIT"
validationInterval="30000"
defaultAutoCommit=true
[keystore.primary]
name = "wso2carbon.jks"
password = "wso2carbon"
[[event_listener]]
id = "mutual_tls_authenticator"
type = "org.wso2.carbon.identity.core.handler.AbstractIdentityHandler"
name = "org.wso2.carbon.identity.oauth2.token.handler.clientauth.mutualtls.MutualTLSClientAuthenticator"
order = "158"
enable = false
ssl_enabled_protocols = ["TLSv1.2"]
[[apim.throttling.url_group]]
traffic_manager_urls = ["tcp://localhost:9611"]
traffic_manager_auth_urls = ["ssl://localhost:9711"]
type = "loadbalance"
[admin_service.wsdl]
enable= true
[tenant_mgt]
enable_email_domain= true
[identity_mgt_account_suspension]
use_identity_claims = false
[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
service_url =
username=
password=
display_in_api_console = true
ws_endpoint="ws://${carbon.local.ip}:9099"
https_endpoint=
[apim.oauth_config]
revoke_endpoint =
[apim.key_manager]
service_url =
username =
password =
[apim.jwt]
enable = true
encoding = "base64" # base64,base64url
generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
claim_dialect = "http://wso2.org/claims"
header = "X-JWT-Assertion"
signing_algorithm = "SHA256withRSA"
enable_user_claims = true
claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever"
[transport.http.properties]
compression = "off"
[transport.https.properties]
compression = "off"
deployment.toml for APIM
[server]
hostname =
node_ip = "127.0.0.1"
#offset=0
serverDetails = "WSO2 IS as KM 5.10.0"
mode = "single" #single or ha
base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
#discard_empty_caches = false
server_role = "default"
userAgent = "WSO2 IS as KM 5.10.0"
[super_admin]
username =
password =
create_admin_account = true
[user_store]
type = "database_unique_id"
[database.apim_db]
type = "postgre"
url = "jdbc:postgresql://wso2_am?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.shared_db]
type = "postgre"
url = "jdbc:postgresql://wso2_shared?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.apim_db.pool_options]
maxActive = "80"
maxWait = "60000"
minIdle = "5"
testOnBorrow = true
validationQuery = "SELECT 1; COMMIT"
validationInterval = "30000"
defaultAutoCommit = true
[database.shared_db.pool_options]
maxActive = "80"
maxWait = "60000"
minIdle = "5"
testOnBorrow = true
validationQuery = "SELECT 1; COMMIT"
validationInterval = "30000"
defaultAutoCommit = true
[database.config]
type = "postgre"
url = "jdbc:postgresql://wso2_shared?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[database.user]
type = "postgre"
url = "jdbc:postgresql://wso2_user?autoReconnect=true&relaxAutoCommit=true&"
username =
password =
driver = "org.postgresql.Driver"
[keystore.tls]
file_name = "wso2carbon.jks"
type = "JKS"
password = "wso2carbon"
alias = "wso2carbon"
key_password = "wso2carbon"
#[keystore.primary]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
#[keystore.internal]
#file_name = "wso2carbon.jks"
#type = "JKS"
#password = "wso2carbon"
#alias = "wso2carbon"
#key_password = "wso2carbon"
[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url =
username=
password=
ws_endpoint =
wss_endpoint =
http_endpoint =
https_endpoint =
[apim.cache.gateway_token]
enable = false
#expiry_time = "900s"
#[apim.cache.resource]
#enable = true
#expiry_time = "900s"
#[apim.cache.km_token]
#enable = false
#expiry_time = "15m"
#[apim.cache.recent_apis]
#enable = false
#[apim.cache.scopes]
#enable = true
#[apim.cache.publisher_roles]
#enable = true
#[apim.cache.jwt_claim]
#enable = true
#expiry_time = "15m"
#[apim.cache.tags]
#expiry_time = "2m"
#[apim.analytics]
#enable = false
#store_api_url = "https://localhost:7444"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#event_publisher_type = "default"
#event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher"
#publish_response_size = true
#[[apim.analytics.url_group]]
#analytics_url =["tcp://analytics1:7611","tcp://analytics2:7611"]
#analytics_auth_url =["ssl://analytics1:7711","ssl://analytics2:7711"]
#type = "loadbalance"
#[[apim.analytics.url_group]]
#analytics_url =["tcp://analytics1:7612","tcp://analytics2:7612"]
#analytics_auth_url =["ssl://analytics1:7712","ssl://analytics2:7712"]
#type = "failover"
[apim.key_manager]
service_url =
username =
password =
#pool.init_idle_capacity = 50
#pool.max_idle = 100
#key_validation_handler_type = "default"
#key_validation_handler_type = "custom"
#key_validation_handler_impl = "org.wso2.carbon.apimgt.keymgt.handlers.DefaultKeyValidationHandler"
#[apim.idp]
#authorize_endpoint = "https://localhost:${mgt.transport.https.port}/oauth2/authorize"
#oidc_logout_endpoint = "https://localhost:${mgt.transport.https.port}/oidc/logout"
[apim.jwt]
enable = true
encoding = "base64" # base64,base64url
generator_impl = "org.wso2.carbon.apimgt.keymgt.token.JWTGenerator"
claim_dialect = "http://wso2.org/claims"
header = "X-JWT-Assertion"
signing_algorithm = "SHA256withRSA"
enable_user_claims = true
claims_extractor_impl = "org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever"
[apim.oauth_config]
#enable_outbound_auth_header = false
#auth_header = "Authorization"
revoke_endpoint =
#enable_token_encryption = false
#enable_token_hashing = false
[apim.devportal]
url =
#enable_application_sharing = false
#if application_sharing_type, application_sharing_impl both defined priority goes to application_sharing_impl
#application_sharing_type = "default" #changed type, saml, default #todo: check the new config for rest api
#application_sharing_impl = "org.wso2.carbon.apimgt.impl.SAMLGroupIDExtractorImpl"
#display_multiple_versions = false
#display_deprecated_apis = false
#enable_comments = true
#enable_ratings = true
#enable_forum = true
[apim.cors]
allow_origins = "*"
allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey"]
allow_credentials = false
#[apim.throttling]
#enable_data_publishing = true
#enable_policy_deploy = true
#enable_blacklist_condition = true
#enable_persistence = true
#throttle_decision_endpoints = ["tcp://localhost:5672","tcp://localhost:5672"]
#[apim.throttling.blacklist_condition]
#start_delay = "5m"
#period = "1h"
#[apim.throttling.jms]
#start_delay = "5m"
#[apim.throttling.event_sync]
#hostName = "0.0.0.0"
#port = 11224
#[apim.throttling.event_management]
#hostName = "0.0.0.0"
#port = 10005
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "loadbalance"
#[[apim.throttling.url_group]]
#traffic_manager_urls = ["tcp://localhost:9611","tcp://localhost:9611"]
#traffic_manager_auth_urls = ["ssl://localhost:9711","ssl://localhost:9711"]
#type = "failover"
#[apim.workflow]
#enable = false
#service_url = "https://localhost:9445/bpmn"
#username = "$ref{super_admin.username}"
#password = "$ref{super_admin.password}"
#callback_endpoint = "https://localhost:${mgt.transport.https.port}/api/am/admin/v0.16/workflows/update-workflow-status"
#token_endpoint = "https://localhost:${https.nio.port}/token"
#client_registration_endpoint = "https://localhost:${mgt.transport.https.port}/client-registration/v0.16/register"
#client_registration_username = "$ref{super_admin.username}"
#client_registration_password = "$ref{super_admin.password}"
#data bridge config
#[transport.receiver]
#type = "binary"
#worker_threads = 10
#session_timeout = "30m"
#keystore.file_name = "$ref{keystore.tls.file_name}"
#keystore.password = "$ref{keystore.tls.password}"
#tcp_port = 9611
#ssl_port = 9711
#ssl_receiver_thread_pool_size = 100
#tcp_receiver_thread_pool_size = 100
#ssl_enabled_protocols = ["TLSv1","TLSv1.1","TLSv1.2"]
#ciphers = ["SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA"]
#[apim.notification]
#from_address = "APIM.com"
#username = "APIM"
#password = "APIM+123"
#hostname = "localhost"
#port = 3025
#enable_start_tls = false
#enable_authentication = true
#[apim.token.revocation]
#notifier_impl = "org.wso2.carbon.apimgt.keymgt.events.TokenRevocationNotifierImpl"
#enable_realtime_notifier = true
#realtime_notifier.ttl = 5000
#enable_persistent_notifier = true
#persistent_notifier.hostname = "https://localhost:2379/v2/keys/jti/"
#persistent_notifier.ttl = 5000
#persistent_notifier.username = "root"
#persistent_notifier.password = "root"
[[event_handler]]
name="userPostSelfRegistration"
subscriptions=["POST_ADD_USER"]
[service_provider]
sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"
[database.local]
url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"
[admin_service.local]
enable = true
As per the shared TOML configurations, a separate UM DB has been configured in both WSO2 IS-KM and API Manager servers. However, only the IS-KM is configured to use the WSO2USER_DB with the following configurations
[realm_manager]
data_source = "WSO2USER_DB"
Add the same configuration to the API Manager's TOML and restart the server.
The realm_manager configuration specifies which DB to use to store Users and Role information. So as of present, the IS-KM uses the UM DB to store the Users and roles whereas the API Manager is using the SHARED DB to store them. When you create an SP, an Application Role is also created along with it. As both APIM and IS-KM are using two different DBs to store the Users and Roles information (due to missing realm_manager configuration), the SPs are not getting visible on either side.
Standard attributes like gender, birthdate are not visible in AWS Cognito, only email exists
resource "aws_cognito_user_pool" "user-pool" {
name = "user-pool-${terraform.workspace}"
alias_attributes = ["email"]
auto_verified_attributes = ["email"]
mfa_configuration = "OFF"
schema {
name = "email"
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
required = true
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
schema {
name = "gender"
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
required = false
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
schema {
name = "birthdate"
attribute_data_type = "String"
required = false
developer_only_attribute = false
mutable = true
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
password_policy {
minimum_length = "8"
require_lowercase = false
require_numbers = false
require_symbols = false
require_uppercase = false
}
}
I've tried deleting users pool manually but it still the same
https://user-images.githubusercontent.com/43336228/105615040-be75c480-5dcd-11eb-8ce0-d9227bac1b26.png
Only email has checkbox while birthdate and gender does not
schema = [{
name = "gender"
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
required = false
string_attribute_constraints = {
min_length = 1
max_length = 2048
}
}, {
name = "birthdate"
attribute_data_type = "String"
required = false
developer_only_attribute = false
mutable = true
string_attribute_constraints = {
min_length = 1
max_length = 2048
}
}]
Above code does not work aswell.
I'm getting error:
Error: Unsupported argument
on cognito.tf line 9, in resource "aws_cognito_user_pool" "user-pool":
9: schema = [{
You have birthday and gender as not required. So the screenshot is correct, as it only indicates required attributes. To make them required, and thus, show in the attributes list you have to do:
resource "aws_cognito_user_pool" "user-pool" {
name = "user-pool-${terraform.workspace}"
alias_attributes = ["email"]
auto_verified_attributes = ["email"]
mfa_configuration = "OFF"
schema {
name = "email"
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
required = true
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
schema {
name = "gender"
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
required = true
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
schema {
name = "birthdate"
attribute_data_type = "String"
required = true
developer_only_attribute = false
mutable = true
string_attribute_constraints {
min_length = 1
max_length = 2048
}
}
password_policy {
minimum_length = "8"
require_lowercase = false
require_numbers = false
require_symbols = false
require_uppercase = false
}
}
I have a custom User model with which I want to validate. The model is use like this:
class GalaxyUser(AbstractBaseUser):
#id = models.IntegerField(primary_key=True)
#identifier = models.CharField(max_length=40, unique=True, db_index=True)
username = models.CharField(max_length=90, unique=True, db_index=True)
create_time = models.DateTimeField(null=True, blank=True)
update_time = models.DateTimeField(null=True, blank=True)
email = models.CharField(max_length=225)
#password = models.CharField(max_length=120)
external = models.IntegerField(null=True, blank=True)
deleted = models.IntegerField(null=True, blank=True)
purged = models.IntegerField(null=True, blank=True)
form_values_id = models.IntegerField(null=True, blank=True)
disk_usage = models.DecimalField(null=True, max_digits=16, decimal_places=0, blank=True)
#last_login = models.TextField(max_length=255)
objects = UserManager()
USERNAME_FIELD = 'email'
class Meta:
db_table = u'galaxy_user'
I have custom Authentication Backend:
class AuthBackend:
def authenticate(self, username=None, password=None):
if '#' in username:
kwargs = {'email': username}
else:
kwargs = {'username': username}
try:
user = User.objects.get(**kwargs)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
def get_user(self, user_id):
try:
return User.objects.get(pk=user_id)
except User.DoesNotExist:
return None
My login_backend function in the views look like this:
def login_backend(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
password = hashlib.sha1(password).hexdigest()
user = authenticate(username=username, password=password)
state = "Username or Password Incorrect!"
if user is not None:
login(request, user)
return HttpResponseRedirect('/overview/')
else:
return render_to_response('login_backend.html', {'state':state}, context_instance=RequestContext(request))
else:
return render_to_response('login_backend.html', context_instance=RequestContext(request))
Despite entering the correct username and password I am not able to login. What's the problem?
Edit:
url(r'^overview/', 'fileupload.views.show_files')
#login_required(login_url='/login_backend/')
def show_files(request):
try:
log_id = request.user.id
username = request.user.username
b = File.objects.filter(users_id=log_id, flag='F', flag_r='S') # Get the user id from session .delete() to use delete
total_files = File.objects.filter(users_id=log_id, flag='F').count()
total_size = File.objects.filter(users_id=log_id, flag='F')
a = [str(i.size) for i in total_size]
x = [convert_byte(i) for i in a]
if request.GET:
if request.GET.getlist('page'):
page = request.GET.getlist('page')
page = ''.join(page)
page = int(page)
else:
page = 1
if request.GET.getlist('limit'):
limit = request.GET.getlist('limit')
limit = ''.join(limit)
limit = int(limit)
else:
limit = 4
if request.GET.getlist('page2'):
page2 = request.GET.getlist('page2')
page2 = ''.join(page2)
page2 = int(page2)
else:
page2 = 1
if request.GET.getlist('limit2'):
limit2 = request.GET.getlist('limit2')
limit2 = ''.join(limit2)
limit2 = int(limit2)
else:
limit2 = 4
else:
page = 1
limit = 4
page2 = 1
limit2 = 4
ten = ''
twenty = ''
fifty = ''
hundred = ''
two_hundred = ''
if limit == 10:
ten = 'selected'
if limit == 20:
twenty = 'selected'
if limit == 50:
fifty = 'selected'
if limit == 100:
hundred = 'selected'
if limit == 200:
two_hundred = 'selected'
ten2 = ''
twenty2 = ''
fifty2 = ''
hundred2 = ''
two_hundred2 = ''
if limit2 == 10:
ten2 = 'selected'
if limit2 == 20:
twenty2 = 'selected'
if limit2 == 50:
fifty2 = 'selected'
if limit2 == 100:
hundred2 = 'selected'
if limit2 == 200:
two_hundred2 = 'selected'
if total_size == None:
total_size = 0
total_size = humansize(sum(x))
current_file = Queue.objects.filter(user_id=log_id)
current_time = (time.time())
x = [i.time_overview for i in current_file]
y = [str(i) for i in x]
durations = [current_time - float(i) for i in y]
test = [i.size for i in current_file]
testi = [str(i) for i in test]
size_overs = [int(i) for i in testi]
email_notify = [i.flag_email for i in current_file]
email_notify = [str(i) for i in email_notify]
zero = [i.replace('0', '') for i in email_notify]
one = [i.replace('1', 'checked') for i in zero]
j = [i.file_session for i in current_file]
k = [str(i) for i in j]
s = ['/home/zurelsoft/files/'+i+'*' for i in k]
a = [os.path.getsize(f) for i in s for f in glob.glob(i+'*')]
change_size = [int(k) for k in a]
queue_count = Queue.objects.filter(user_id=log_id).count()
recent_count = File.objects.filter(users_id=log_id, flag='F', flag_r='S').count()
return render_to_response('overview.html', {'queue_count':queue_count, 'recent_count':recent_count, 'page2':page2, 'limit2':limit2, 'ten2':ten2, 'twenty2':twenty2, 'fifty2':fifty2, 'hundred2':hundred2, 'two_hundred2':two_hundred2, 'ten':ten, 'twenty':twenty, 'fifty':fifty, 'hundred':hundred, 'two_hundred':two_hundred, 'page':page, 'limit':limit, 'email_notify':one, 'change_size':change_size, 'duration':durations, 'size_over':size_overs, 'overview':current_file, 'overview_files': b, 'total_files':total_files, 'total_size':total_size, 'username': username}, context_instance=RequestContext(request))
except OSError:
return render_to_response('overview.html', {'overview_files': b, 'total_files':total_files, 'total_size':total_size, 'username': username}, context_instance=RequestContext(request))
You shouldn't be hashing the submitted password in the view. The backend does that for you when you call the User.check_password method.
Change in your view
def login_backend(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
#password = hashlib.sha1(password).hexdigest()
#user = authenticate(username=username, password=password)
state = "Username or Password Incorrect!"
if user is not None:
login(request, user)
return HttpResponseRedirect('/overview/')
else:
return render_to_response('login_backend.html', {'state':state}, context_instance=RequestContext(request))
else:
return render_to_response('login_backend.html', context_instance=RequestContext(request))