I recently decided to move our district away from custom scripts for identity management and automation, towards a product provided by Tools4Ever, NIM. While doing so, I realized that NIM is a pretty powerful utility. NIM provides the ability for end users to develop custom connectors & internal applications, making NIM more than just a utility for automated identity management.
While the team at Tools4Ever is happy to take your money to develop a new connector, I work in education, I don't have money. Enter the documentation provided by NIM, full of useful information. Paired with their connector GitHub, anyone can build a connector, as long as your chosen product's API plays nice.
I decided to develop a connector for PacketFence, our district NAC. This would allow me to create a NIM app for revoking certificates, which would prevent campus technicians from needing access to the configuration portal of PacketFence to find the same functionality. I've shared the connector on Github for anyone interested in utilizing or contributing to it.
Prerequisites:
- Basic understanding of NIM and API integrations
- Access to the PacketFence API documentation
- Access to the NIM Connector documentation
- Access to the NIM Github (for examples)
Challenge: Response Format Mismatch
One hurdle to address is the current content header of PacketFence API responses. Unlike the typical JSON format expected by NIM, PacketFence delivers data in plain text (text/plain
). This mismatch prevents NIM from automatically parsing the response data, the data is provided in the JSON format, it's the header that is incorrect.
Solution: HTTP Interceptor
To overcome this limitation, we'll leverage an HTTP interceptor, I chose Requestly. By functioning as a proxy, the interceptor can intercept communication between NIM and the PacketFence API. Here's the key step: within the interceptor, we can modify the response headers to convert the response format from plain text to JSON (application/json
). With this adjustment, NIM will be able to interpret the data seamlessly.
Implementation Steps:
Create the NIM Connector:
- Utilize NIM's documentation and reference existing connectors to create the custom PacketFence JSON connector.
- Test & troubleshoot PacketFence endpoints via Postman.
- Test & troubleshoot the PacketFence connector in NIM via Fiddler.
Deploy the HTTP Interceptor:
- Configure Requestly (or your chosen interceptor) to act as a proxy for the communication between NIM and the PacketFence API.
- Within the interceptor, rewrite the response headers to indicate a JSON format (
application/json
). - Enable the proxy option for the PacketFence connector and point it to your interceptor.
Conclusion:
Building custom connectors can involve unexpected challenges. Here, the PacketFence API's response format presented a roadblock. However, by leveraging HTTP interceptors, we can effectively bridge this gap and achieve successful data integration within NIM.
I've published the connector to my Github page for anyone interested in making use of it, at the moment I've only created NIM objects to poll the PacketFence Users and Certificates API.