You can create a private version of the Developer Portal, so that authenticated users only can access content on the site. You might want to do this if you want to restrict public access to your content unless they are logged in. This has been covered in this tutorial. This post demonstrates the way page variants can be used to change the home page of a developer portal site depending on whether a user is logged in or not.
Export your configuration settings
In case of slip ups in changing the site permissions, backup your configuration settings using the toolkit CLI. This is covered in the IBM docs tutorial Exporting and importing custom themes and site configuration which provides further details on how to do this.
Warning - as the Welcome page is content and NOT configuration it is not currently possible to backup and then restore the page – if you make a mistake here then it would be difficult to get back to the default Welcome page, without recreating the site entirely. To be extra safe another option would be to create a completely new home page from the tutorial Changing the front page to replicate the Welcome page or page you wish to see and to then create variants on that page according to the user role.
Restrict all permissions to authenticated users
As previously outlined in this IBM documentation tutorial – log in as an administrator to the portal site. Navigate to Manage, People, Permissions. Clear all check boxes that are associated with the anonymous user. Click Save at the bottom of the permissions page.
Create a page variant for the Welcome page
In this example, we are adding a page variant to the existing default welcome page – this is intended to be identical to the default page but not include all the blocks on the existing welcome page.
As admin Manage, Structure, Pages. Click Edit next to the Welcome page.
Click the Variant “Panels” – this is the default page created on site creation.
- Click “Selection Criteria”
- Select “User Role” , click “Add Condition”
- Check “Authenticated user”, click Save.
- Click “Update and save”
- Select the Add variant tab.
- Page variant type form
- Label: “Anonymous”
- Type: Panels
- Do not check any optional features, click Next
- Builder: Standard, click Next
- Layout: Bootstrap, One column, click Next
- Layout Settings: Keep all defaults except for Region: Content, Classes – select “Row”, click Next
- Page title: leave blank
- Add New block, click and select for each desired block, select, uncheck “Display title”, click “Add block”:
- Click “Finish” once all blocks you want to display on anonymous log in page have been added. Tip: check the ordering of the blocks, rearrange either by displaying the row weights and altering or hide them and use the drag and drop icons to rearrange.
- Click “Update and Save”.
- Though you can use the page variant by modifying which blocks which user role sees, the best way to manage whether a user can see or not see an API or an API Product is by setting the visibility on it when publishing it to the catalog.
- You can have more than one page variant and set selection criteria on each page variant. The order in which the rules are applied and satisfied is determined by the order in which the page variants are ordered – this can be changed via the “Reorder variants” tab
- Tip - alternative, would be to have negate condition on the “Anonymous” variant, you need to check the order of the page variants.
- You can delete a page variant on the General section for that variant – USE WITH CAUTION
- For this example, I did not hide the Sign in or Create Account links from the menu bar – which is possible by following the steps in the previously mentioned tutorial. Managing whether the user can see and use the “Create Account” link is determined by whether the provider organisation owner has set self-sign up for the site catalog.
- The admin link on the login page can be hidden by following the steps detailed in this topic in the IBM Documentation.
As you can see from this example, there are many ways to configure and create content in your Developer Portal to achieve the user experience you want to deliver to your API consumers.