HAT Data Plugs written in Scala/Play
DataPlugs in the HAT ecosystem are self-contained services that act between a service providing data and a HAT. This project provides reusable libraries and structures for building such DataPlugs as well as examples of already built ones.
The proposed implementation is built on the Scala/Play framework and
contains a universal core component (dataplug
subproject) for any DataPlug.
It also relies on convenience API wrappers served as HAT Library Artifacts:
hat-client-scala-play
as a Scala wrapper around the HAT HTTP APIdex-client-scala-play
as a Scala wrapper around the Dataswift's Dex HTTP API
DataPlug Core implementation takes care of:
- HAT Login
- Social login (via "Silhouette") with common OAuth1/OAuth2 implementations provided and customisable
- Source Endpoint API subscription management
- Synchronisation scheduling and management using Akka Actors
- Basic UI views
- Implement API endpoint interfaces (e.g.
GoogleCalendarInfo
) - Strongly suggested but optional - implement Strongly-typed classes describing API data structures
- Tweak the way mapping is done between those structures and the HAT
- Override any implementations of existing UI views
- Tie everything together using Dependency Injection
- Provide application configuration and social network (data source) API credentials
You will also need to extend project build settings to include the new plug, please see build.sbt
for an example
The following configuration parameters need to be provided as environment variables:
APPLICATION_SECRET
- application secretMAILER_FROM
- emailFrom
field value*HAT_USER
- username of the dedicated dataplug account on HATsHAT_PASSWORD
- password of the dedicated dataplug account on HATsDEX_DATAPLUG_ID
- dataplug ID on DEX registryDEX_ACCESS_TOKEN
- access token for DEX API requestsSERVICES_SECRET
- shared secret for Dataswift's HAT servicesDATABASE_URL
- database URLDATABASE_USER
- database usernameDATABASE_PASSWORD
- database passwordCOOKIE_SIGNER_KEY
- cookie signer keyCRYPTER_KEY
- crypter key
- marked environment variables can be left unspecified in the development setup
Server configuration can be customised by adjusting parameters in conf/application.conf
file. To run the project
locally in the development mode the following settings might need changing:
auth.allowedResources
- include server's domain name in the listdexter.secure
- boolean value to indicate if the connection to the HAT should be made securely over HTTPSservice.secure
- boolean value to indicate if the server content is being served over secure connection (HTTPS)
TWITTER_CONSUMER_KEY
- Twitter app's consumer keyTWITTER_CONSUMER_SECRET
- Twitter app's consumer secret
GOOGLE_CALLBACK_URL
- Google OAuth callback URLGOOGLE_CLIENT_ID
- Google app's client IDGOOGLE_CLIENT_SECRET
- Google app's secret token
The dataplug can be run locally by executing
sbt "project dataplug-{providerName}" "run -Dconfig.resource=application.dev.conf"
Facebook and Instagram plugs require the use of https
. To run those plugs locally you have to execute
sbt "project dataplug-(providenName)" "run -Dconfig.resource=application.dev.conf -Dhttps.port=9443"
This code is licensed under the Mozilla Public License Version 2.0. Please read the LICENSE.md file for further details.