-
Notifications
You must be signed in to change notification settings - Fork 1
Service Requests
Controllers: Basics | Use | Config | Service Requests | Users & Tokens
A ServiceConnection is normally used to make requests to services built with core3. Each instance can communicate with only one service at a time, so if access to more services is needed, multiple instances should be created.
While a ServiceConnection can also be used to communicate with a Workflow Engine service, it is probably easier to use a WorkflowEngineConnection (depending on the service implementation).
Requests can be sent to Microsoft's Graph API via the Graph Service Connection. For more information, check the appropriate wiki page.
Some other useful bits of information:
- Controllers - Basics
- Controllers - Config
- Controllers - Use
- Example backend service
- Example frontend
- Microsoft Graph Connection
When using Auth0 as the auth provider, having multiple routes is only possible by having multiple controllers, as the API configuration is bound to the route (API Identifier). Below is a simple example implementation with two routes/services.
server.static {
...
security {
authentication {
services {
SOME_AUTH0_API_NAME_FOR_USER_SERVICE {
id = "<some ID>"
identifier = "https://<some host & port>/service/users"
}
SOME_AUTH0_API_NAME_FOR_CLIENT_SERVICE {
id = "<some other ID>"
identifier = "https://<some host & port>/service/clients"
}
}
clients {
SOME_AUTH0_CLIENT_NAME {
//... standard client config for the current app ...
}
}
}
}
...
}import akka.actor.ActorSystem
import akka.stream.Materializer
import com.google.inject.{AbstractModule, Provides, Singleton}
import core3.config.StaticConfig
import core3.http.requests.{auth0, WorkflowEngineConnection}
import play.api.Environment
import play.api.libs.ws.WSClient
import scala.concurrent.ExecutionContext
//simple container class
case class WorkflowEngineConnections(users: WorkflowEngineConnection, clients: WorkflowEngineConnection)
class Module extends AbstractModule {
//... other providers ...
@Provides
@Singleton
def provideEngineConnections(
ws: WSClient,
system: ActorSystem,
environment: Environment
)(implicit ec: ExecutionContext): WorkflowEngineConnections = {
WorkflowEngineConnections(
users = new WorkflowEngineConnection(
system.actorOf(
auth0.ServiceConnectionComponent.props(
ws,
StaticConfig.get.getConfig(
"security.authentication.services.<SOME_AUTH0_API_NAME_FOR_USER_SERVICE>"
),
StaticConfig.get.getConfig(
"security.authentication.clients.<SOME_AUTH0_CLIENT_NAME>"
)
)
)
),
clients = new WorkflowEngineConnection(
system.actorOf(
auth0.ServiceConnectionComponent.props(
ws,
StaticConfig.get.getConfig(
"security.authentication.services.<SOME_AUTH0_API_NAME_FOR_CLIENT_SERVICE>"
),
StaticConfig.get.getConfig(
"security.authentication.clients.<SOME_AUTH0_CLIENT_NAME>"
)
)
)
)
)
}
//... other providers
}server.static {
...
security {
authentication {
services {
SOME_LOCAL_AUTH_SERVICE_NAME {
uri = "https://<some host & port>/service/users"
serviceUser = "<some service user name>"
serviceUserPassword = "<some service user password>"
}
}
clients {
SOME_LOCAL_AUTH_CLIENT_NAME {
//... standard client config for the current app ...
}
}
}
}
}import akka.actor.ActorSystem
import com.google.inject.{AbstractModule, Provides, Singleton}
import core3.config.StaticConfig
import core3.http.requests.{WorkflowEngineConnection, local}
import play.api.Environment
import play.api.libs.ws.WSClient
import scala.concurrent.ExecutionContext
class Module extends AbstractModule {
//... other providers ...
@Provides
@Singleton
def provideEngineConnection(
ws: WSClient,
system: ActorSystem,
environment: Environment
)(implicit ec: ExecutionContext): WorkflowEngineConnection = {
new WorkflowEngineConnection(
system.actorOf(
local.ServiceConnectionComponent.props(
ws,
StaticConfig.get.getConfig(
"security.authentication.services.<SOME_LOCAL_AUTH_SERVICE_NAME>"
)
)
)
)
}
//... other providers ...
}Home | Getting Started | Structure | Containers | Workflows | Controllers