Tenant-specific Devportal & Publisher Service Providers
Configure Per-Tenant Devportal & Publisher Service Providers in WSO2 API Manager 3.2.0
Greetings Everyone !!! 👋
In this medium, I will be going over the configurations and the steps to create tenant-specific Service Providers for the Publisher and Devportal in WSO2 API Manager v3.2.0.
The Tenant-specific Service Provider creation for both Publisher and Devportal is supported by WSO2 API Manager from v3.1.0 onwards
Let's Get Started !!! 🙌
✋ Configure WSO2 API Manager
First, we are going to create a sample tenant named foo.com
in the WSO2 API Manager v3.2.0.
Let’s fire up the WSO2 API Manager server and log-in to the Carbon Management console using the super admin credentials. Then direct to Configure
section and click on Add New Tenant
to create a new tenant.
On the following screen, fill in the required information with your favorite values and click on Save to create the tenant. Given below is a screenshot of the foo.com
tenant configurations
Next, we are going to introduce a custom URL mapping for our tenant.
Go back to the Main
view and direct to Resources
> Browse
> _system
and click on governance
. On the next screen, select the Add Collection
option under the Entries section to create a new collection.
Enter the following and click on Add
to create the registry collection
- Name:
customurl/api-cloud/foo.com/urlMapping
The above will create a registry collection for us under the governance
collection.
Once the collection is successfully created, navigate to the specified location (_system/governance/customurl/api-cloud/<tenant-domain>/urlMapping
) and click on Add Resource
to add a registry artifact.
Input the following
- Method:
Create Text content
- Name:
foo.com
(the name of the artifact must follow the tenant domain name) - Media Type:
text/plain
And add the following as the content …
{
"tenantDomain": "foo.com",
"store": {
"customUrl": "devportal.foo.com"
},
"gateway": {
"customUrl": "gw.foo.com"
}
}
And click on Add
to save the artifact. The above specifies that the Devportal and the Gateway of the tenant foo.com
will be accessed through the specified custom URLs.
For Publisher portals, add
publisher
segment along with the above-mentioned JSON configurations
We are now done with the initial set of configurations mentioning the custom URL mappings for our tenants. Now, it’s time to configure our tenants to create tenant-specific Service Providers.
Logout from the Carbon Management console and log-in back again with the Tenant Admin credentials. After a successful login, go to Resources
> Browse
> _system
> config
> apimgt
> applicationdata
and open and edit the tenant-conf.json
artifact.
On the next screen, select the Edit as text
option and add the following property to the JSON to enable tenant-specific Service Provider creation
"EnablePerTenantServiceProviderCreation": true
And click on Save Content
to save our configurations. And we have successfully completed the configurations related to URL mapping and tenant-specific Service Provider configurations at the WSO2 API Manager.
To test the scenarios, we need to create a set of Nginx routes and configurations to route the specified custom URL mappings to specific endpoints of the API Manager server.
✋ Configure Nginx
Attached is a sample Nginx configuration, routing the devportal.foo.com
and gw.foo.com
requests to the tenant-specific endpoints in the WSO2 API Manager
server {
listen 443 ssl;
server_name "devportal.foo.com";
proxy_set_header X-Forwarded-Port 443;
# ssl certificate configurations
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_pass https://localhost:9443/devportal/;
proxy_redirect https://localhost:9443/devportal/ /;
proxy_set_header X-WSO2-Tenant "foo.com";
} location ~ (/api/am/store/v1|oauth2|/authenticationendpoint|/logincontext|/commonauth|/oidc) {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_pass https://localhost:9443;
proxy_set_header X-WSO2-Tenant "foo.com";
}
}server {
listen 443 ssl;
server_name "gw.foo.com"; # ssl configurations location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_pass https://localhost:8243/t/foo.com/;
}
}
🎉 Voila!!! 🎉
We have successfully configured the API Manager and the Nginx to create and access the Tenant specific endpoints and the Service Providers of the API Manager server.
Test Scenario
Deploy the Nginx configurations in your environment and start accessing the Tenant Devportal by navigating to https://devportal.foo.com
from your favorite browser. After a successful login to the Tenant Devportal, try logging-in to the Carbon Management console with the Tenant credentials and there you will find a Service Provider created for the Devportal under the Service Providers section.