@abgov/adsp-sdk-mcp-server 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/assets/docs/architecture.md +79 -0
- package/assets/docs/getting-started.md +118 -0
- package/assets/docs/important-notes.md +47 -0
- package/assets/docs/index.md +9 -0
- package/assets/docs/platform/deployment.md +80 -0
- package/assets/docs/platform/getting-started.md +66 -0
- package/assets/docs/platform/operations.md +8 -0
- package/assets/docs/platform/platform-django-sdk.md +330 -0
- package/assets/docs/platform/platform-dotnet-sdk.md +457 -0
- package/assets/docs/platform/platform-flask-sdk.md +355 -0
- package/assets/docs/platform/platform-node-sdk.md +433 -0
- package/assets/docs/platform/platform-spring-sdk.md +344 -0
- package/assets/docs/platform/platform.md +8 -0
- package/assets/docs/services/access-service.md +75 -0
- package/assets/docs/services/agent-service.md +316 -0
- package/assets/docs/services/cache-service.md +61 -0
- package/assets/docs/services/calendar-service.md +86 -0
- package/assets/docs/services/comment-service.md +87 -0
- package/assets/docs/services/configuration-service.md +92 -0
- package/assets/docs/services/directory-service.md +57 -0
- package/assets/docs/services/event-service.md +122 -0
- package/assets/docs/services/feedback-service.md +152 -0
- package/assets/docs/services/file-service.md +164 -0
- package/assets/docs/services/form-service.md +149 -0
- package/assets/docs/services/notification-service.md +151 -0
- package/assets/docs/services/pdf-service.md +116 -0
- package/assets/docs/services/pii-service.md +45 -0
- package/assets/docs/services/push-service.md +106 -0
- package/assets/docs/services/services.md +6 -0
- package/assets/docs/services/status-service.md +29 -0
- package/assets/docs/services/task-service.md +139 -0
- package/assets/docs/services/tenant-service.md +18 -0
- package/assets/docs/services/token-handler.md +135 -0
- package/assets/docs/services/value-service.md +80 -0
- package/assets/docs/services/verify-service.md +61 -0
- package/assets/docs/tutorials/access-service/access-service.md +9 -0
- package/assets/docs/tutorials/access-service/adsp-clients.md +29 -0
- package/assets/docs/tutorials/access-service/application-clients.md +61 -0
- package/assets/docs/tutorials/access-service/front-end-access.md +53 -0
- package/assets/docs/tutorials/access-service/introduction.md +33 -0
- package/assets/docs/tutorials/access-service/tenants.md +68 -0
- package/assets/docs/tutorials/access-service/themes.md +43 -0
- package/assets/docs/tutorials/feedback-service/accessing-data.md +41 -0
- package/assets/docs/tutorials/feedback-service/feedback-service.md +9 -0
- package/assets/docs/tutorials/feedback-service/installation.md +142 -0
- package/assets/docs/tutorials/feedback-service/introduction.md +28 -0
- package/assets/docs/tutorials/feedback-service/security.md +40 -0
- package/assets/docs/tutorials/feedback-service/triggering.md +21 -0
- package/assets/docs/tutorials/file-service/file-service.md +9 -0
- package/assets/docs/tutorials/file-service/file-types.md +35 -0
- package/assets/docs/tutorials/file-service/introduction.md +34 -0
- package/assets/docs/tutorials/file-service/security.md +31 -0
- package/assets/docs/tutorials/file-service/working-with.md +65 -0
- package/assets/docs/tutorials/form-service/Integration.md +31 -0
- package/assets/docs/tutorials/form-service/ai-agent.md +450 -0
- package/assets/docs/tutorials/form-service/building-forms.md +264 -0
- package/assets/docs/tutorials/form-service/cheat-sheet.md +1461 -0
- package/assets/docs/tutorials/form-service/custom-error-messages.md +87 -0
- package/assets/docs/tutorials/form-service/data-registers.md +204 -0
- package/assets/docs/tutorials/form-service/file-uploader.md +81 -0
- package/assets/docs/tutorials/form-service/form-app.md +72 -0
- package/assets/docs/tutorials/form-service/form-editor.md +62 -0
- package/assets/docs/tutorials/form-service/form-service.md +9 -0
- package/assets/docs/tutorials/form-service/form-submissions.md +77 -0
- package/assets/docs/tutorials/form-service/instructions.md +173 -0
- package/assets/docs/tutorials/form-service/introduction.md +66 -0
- package/assets/docs/tutorials/form-service/repeated-items.md +87 -0
- package/assets/docs/tutorials/form-service/security.md +36 -0
- package/assets/docs/tutorials/form-service/steppers.md +237 -0
- package/assets/docs/tutorials/notification-service/emailAttachment.md +75 -0
- package/assets/docs/tutorials/notification-service/events.md +20 -0
- package/assets/docs/tutorials/notification-service/introduction.md +37 -0
- package/assets/docs/tutorials/notification-service/notification-service.md +9 -0
- package/assets/docs/tutorials/notification-service/notification-types.md +86 -0
- package/assets/docs/tutorials/notification-service/subscribers.md +33 -0
- package/assets/docs/tutorials/pdf-service/building-a-template.md +339 -0
- package/assets/docs/tutorials/pdf-service/generate-a-pdf.md +150 -0
- package/assets/docs/tutorials/pdf-service/handlebars.md +51 -0
- package/assets/docs/tutorials/pdf-service/introduction.md +26 -0
- package/assets/docs/tutorials/pdf-service/pdf-service.md +9 -0
- package/assets/docs/tutorials/pdf-service/puppeteer.md +25 -0
- package/assets/docs/tutorials/pdf-service/video.md +18 -0
- package/assets/docs/tutorials/status-service/Introduction.md +46 -0
- package/assets/docs/tutorials/status-service/health.md +51 -0
- package/assets/docs/tutorials/status-service/notices.md +34 -0
- package/assets/docs/tutorials/status-service/notifications.md +107 -0
- package/assets/docs/tutorials/status-service/status-service.md +9 -0
- package/assets/docs/tutorials/status-service/status.md +35 -0
- package/assets/docs/tutorials/status-service/webhooks.md +24 -0
- package/assets/docs/tutorials/task-service/introduction.md +23 -0
- package/assets/docs/tutorials/task-service/task-app.md +43 -0
- package/assets/docs/tutorials/task-service/task-definitions.md +49 -0
- package/assets/docs/tutorials/task-service/task-queues.md +67 -0
- package/assets/docs/tutorials/task-service/task-service.md +9 -0
- package/assets/docs/tutorials/tutorials.md +8 -0
- package/package.json +18 -0
- package/src/docs/docsRepository.d.ts +22 -0
- package/src/docs/docsRepository.js +110 -0
- package/src/docs/docsRepository.js.map +1 -0
- package/src/main.d.ts +2 -0
- package/src/main.js +16 -0
- package/src/main.js.map +1 -0
- package/src/sdk-reference/reference.d.ts +17 -0
- package/src/sdk-reference/reference.js +547 -0
- package/src/sdk-reference/reference.js.map +1 -0
- package/src/sdk-reference/search.d.ts +6 -0
- package/src/sdk-reference/search.js +41 -0
- package/src/sdk-reference/search.js.map +1 -0
- package/src/server.d.ts +6 -0
- package/src/server.js +30 -0
- package/src/server.js.map +1 -0
- package/src/tools/registerDocsTools.d.ts +3 -0
- package/src/tools/registerDocsTools.js +66 -0
- package/src/tools/registerDocsTools.js.map +1 -0
- package/src/tools/registerQuickstartTool.d.ts +2 -0
- package/src/tools/registerQuickstartTool.js +82 -0
- package/src/tools/registerQuickstartTool.js.map +1 -0
- package/src/tools/registerSdkTools.d.ts +2 -0
- package/src/tools/registerSdkTools.js +43 -0
- package/src/tools/registerSdkTools.js.map +1 -0
- package/src/tools/types.d.ts +12 -0
- package/src/tools/types.js +3 -0
- package/src/tools/types.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @abgov/adsp-sdk-mcp-server
|
|
2
|
+
|
|
3
|
+
An MCP (Model Context Protocol) server that gives an AI coding assistant grounded, sourced answers about the
|
|
4
|
+
[Alberta Digital Service Platform](https://govalta.github.io/adsp-monorepo) (ADSP) and the Node SDK
|
|
5
|
+
(`@abgov/adsp-service-sdk`), instead of guessing.
|
|
6
|
+
|
|
7
|
+
It bundles the ADSP documentation site content and a curated reference of every `@abgov/adsp-service-sdk` export,
|
|
8
|
+
and exposes them over stdio via four tools:
|
|
9
|
+
|
|
10
|
+
- `search_adsp_docs` — keyword search across ADSP platform docs (getting started, architecture, service concepts,
|
|
11
|
+
tutorials).
|
|
12
|
+
- `read_adsp_doc` — read the full content of a doc page found via search.
|
|
13
|
+
- `search_sdk_reference` — search `@abgov/adsp-service-sdk` by symbol name, module, or keyword; returns full symbol
|
|
14
|
+
details (kind, description, option/return shape, example, deprecated flag).
|
|
15
|
+
- `get_platform_quickstart` — the canonical `initializePlatform` usage pattern and a capabilities summary, for the
|
|
16
|
+
most common question: how to start using ADSP from a Node service.
|
|
17
|
+
|
|
18
|
+
This package covers the Node SDK only. Other language SDKs (`.NET`, Django, Flask, Spring) are out of scope for now.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
Add it to your MCP client's server config, run via `npx`:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"mcpServers": {
|
|
27
|
+
"adsp-sdk": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@abgov/adsp-sdk-mcp-server"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
nx build adsp-sdk-mcp-server
|
|
39
|
+
nx test adsp-sdk-mcp-server
|
|
40
|
+
nx lint adsp-sdk-mcp-server
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To try it locally against a real MCP client, point the client config's `command`/`args` at the built entry point
|
|
44
|
+
instead of `npx`:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"command": "node",
|
|
49
|
+
"args": ["<repo>/dist/libs/adsp-sdk-mcp-server/src/main.js"]
|
|
50
|
+
}
|
|
51
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Architecture
|
|
4
|
+
nav_order: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<details open markdown="block">
|
|
8
|
+
<summary>
|
|
9
|
+
Table of contents
|
|
10
|
+
</summary>
|
|
11
|
+
{: .text-delta }
|
|
12
|
+
1. TOC
|
|
13
|
+
{:toc}
|
|
14
|
+
</details>
|
|
15
|
+
|
|
16
|
+
# Architecture
|
|
17
|
+
ADSP is a suite of micro-services providing commonly needed capabilities and designed to help teams deliver faster. It is oriented around convention-based and opinionated implementations of a few high level concepts including:
|
|
18
|
+
|
|
19
|
+
- Multi-tenancy,
|
|
20
|
+
- Service discovery,
|
|
21
|
+
- Configuration management, and
|
|
22
|
+
- Domain events.
|
|
23
|
+
|
|
24
|
+
The project is structured as a monorepo, and development of platform and tenant services is supported by a set of [SDKs](./platform/platform-node-sdk.md) for popular application frameworks.
|
|
25
|
+
|
|
26
|
+
## Multi-tenancy
|
|
27
|
+
ADSP is designed to be a multi-tenant system and all platform micro-services support tenant requests as well as requests in a **Core (System)** context.
|
|
28
|
+
|
|
29
|
+
The [Tenant service](./services/tenant-service.md) acts as a register of tenants and each tenant is associated with a JWT issuer (keycloak realm). Services retrieve this information via the tenant service API.
|
|
30
|
+
|
|
31
|
+
Users and tenant service accounts are authenticated against tenant realms and their requests include JWT bearer tokens signed by the tenant issuer. Platform services verify tokens and map requests to the appropriate tenant context based on the issuer.
|
|
32
|
+
|
|
33
|
+
### Tenant isolation
|
|
34
|
+
ADSP does not use a per tenant instancing approach. Each platform service is a horizontally scaled set of pods that all tenants share. Platform services use the request tenant context to scope API requests to tenant specific records. Platform service accounts are in the **Core** context and are permitted to specify the request tenant context.
|
|
35
|
+
|
|
36
|
+
How a platform service manages storing tenant specific data is an implementation detail of that service. In general, records are kept in the same database, and each record is stored with a tenant identifier. This is weak tenant isolation, and should be considered if ADSP is used in a different context.
|
|
37
|
+
|
|
38
|
+
## Service discovery
|
|
39
|
+
Clients need to find the services and APIs that provide the capabilities they want to leverage. The [Directory service](./services/directory-service.md) provides a Directory of Services to support client-side service discovery.
|
|
40
|
+
|
|
41
|
+
The directory keeps entries that map service and API logical URNs to URLs. For example, the tenant service API entry is: `urn:ads:platform:tenant-service:v2` -> `https://tenant-service.adsp.alberta.ca`. This allows clients to find capabilities using logical identifiers instead of endpoint URLs which can change across environments and over time.
|
|
42
|
+
|
|
43
|
+
### Directory URN convention
|
|
44
|
+
Platform services use a convention for URNs, which are used in both service client IDs, and hence JWT `aud` claim, and directory entries.
|
|
45
|
+
|
|
46
|
+
The convention is:
|
|
47
|
+
|
|
48
|
+
`urn:ads:<namespace>:<service>:<api>:<resource>`
|
|
49
|
+
|
|
50
|
+
Where
|
|
51
|
+
|
|
52
|
+
- `<namespace>` is "`platform`" for platform services, and expected to be the tenant name in kebab case for tenant services;
|
|
53
|
+
- `<service>` is the kebab case name of the service, for example "`tenant-service`";
|
|
54
|
+
- `<api>` is commonly the API version like "`v2`", and
|
|
55
|
+
- `<resource>` is the subpath to an API resource, for example "`/tenants`".
|
|
56
|
+
|
|
57
|
+
For example, the tenant API tenants resource URN is: `urn:ads:platform:tenant-service:v2:/tenants`.
|
|
58
|
+
|
|
59
|
+
This allows a client to resolve and address a specific API resource via the directory. `urn:ads:platform:tenant-service:v2:/tenants` is resolved to `https://tenant-service.adsp.alberta.ca/api/tenant/v2/tenants`.
|
|
60
|
+
|
|
61
|
+
## Configuration management
|
|
62
|
+
Platform services use configuration to allow capabilities to be tailored to specific uses. For example, the [PDF service](./services/pdf-service.md) uses configuration for the templates used to generate PDFs. [Configuration service](./services/configuration-service.md) provides the model and API for configuration management.
|
|
63
|
+
|
|
64
|
+
### Registration
|
|
65
|
+
Services configure other services through a process of registration. On startup, services make requests to the configuration API to update configuration of other services that they leverage. For example, the [PDF service](./services/pdf-service.md) registers configuration for the [File service](./services/file-service.md) to define its generated PDF file type.
|
|
66
|
+
|
|
67
|
+
Tenant services can also register configuration, and their configuration is scoped to the tenant.
|
|
68
|
+
|
|
69
|
+
## Domain events
|
|
70
|
+
Domain events represent occurrences that are of domain significance. For example, the [Form service](./services/form-service.md) signals a domain event when a form is submitted. The [Event service](./services/event-service.md) provides the API for sending domain events.
|
|
71
|
+
|
|
72
|
+
Domain events are routed over RabbitMQ, and platform services use domain events to trigger effects aside from the service that signalled the event. This allows for augmenting a service with additional capabilities outside its control flow. The [event log](#event-logging) is one such capability that is built into the event service.
|
|
73
|
+
|
|
74
|
+
Tenant services and applications don't have access to the platform RabbitMQ, but can use the [Push service](./services/push-service.md) as a websocket gateway to receive events.
|
|
75
|
+
|
|
76
|
+
### Event logging
|
|
77
|
+
Domain events sent via the event service are routed to an event logging queue. The event service includes a job that consumes queued events and records them in the event log.
|
|
78
|
+
|
|
79
|
+
Typically domain events are associated with domain operations and state changes, and the log can serve as an audit trail of changes. However, services may also signal more transitory events for purposes such as to trigger notifications or scripts, and those events can be configured to be excluded from logging to avoid introducing extraneous noise.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Getting started
|
|
4
|
+
nav_order: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<details open markdown="block">
|
|
8
|
+
<summary>
|
|
9
|
+
Table of contents
|
|
10
|
+
</summary>
|
|
11
|
+
{: .text-delta }
|
|
12
|
+
1. TOC
|
|
13
|
+
{:toc}
|
|
14
|
+
</details>
|
|
15
|
+
|
|
16
|
+
# Getting started
|
|
17
|
+
|
|
18
|
+
Product teams can get started by accessing an existing tenant or creating a new tenant. Each tenant represents a zone of administrative control and generally products within a common service area can share a tenant.
|
|
19
|
+
|
|
20
|
+
**To create a new tenant**
|
|
21
|
+
|
|
22
|
+
1. Go to [ADSP Home](https://adsp.alberta.ca);
|
|
23
|
+
2. Click the _Request a tenant_ button. (You may require approval from the platform team to complete the tenant creation process.)
|
|
24
|
+
3. Congratulations! You have a tenant in ADSP.
|
|
25
|
+
|
|
26
|
+
## Overview of tenant administration
|
|
27
|
+
|
|
28
|
+
The tenant administration app allows you to configure platform services for your tenant. It consists of three general sections:
|
|
29
|
+
|
|
30
|
+
1. Navigation menu allows you to switch between items.
|
|
31
|
+
2. Main content shows the informational and configuration content of the selected item.
|
|
32
|
+
3. Aside that provides links to supporting materials.
|
|
33
|
+
|
|
34
|
+
## Administering your tenant
|
|
35
|
+
|
|
36
|
+
After your tenant is created, you will have access to the tenant administration application. As the original creator of a tenant, you can login from the landing page of ADSP to access tenant administration.
|
|
37
|
+
|
|
38
|
+
For other team members, note the instructions and tenant specific login LRN shown in the aside on the _Dashboard_ view (either on the right or the bottom). Team members can login via this url to provision their user in the tenant realm; they will start with no access to tenant administration.
|
|
39
|
+
|
|
40
|
+
**To grant administration access to team members**
|
|
41
|
+
|
|
42
|
+
1. Select _Services_ -> _Access_ in the navigation menu.
|
|
43
|
+
2. Use the _Keycloak admin portal_ link to access Keycloak realm administration for your tenant.
|
|
44
|
+
3. Select _Manage_ -> _Users_ and click the _View all users_ button.
|
|
45
|
+
4. Select the team member you wish to grant access to, and select _Role Mappings_.
|
|
46
|
+
5. Click _Assign role_, filter by clients, select `urn:ads:platform:tenant-service`, and assign the `tenant-admin` role.
|
|
47
|
+
6. Your team member can now access tenant administration via the tenant specific login url.
|
|
48
|
+
|
|
49
|
+
## Configuring a platform service
|
|
50
|
+
|
|
51
|
+
You can access configuration for the platform services from the left-side navigation menu in tenant administration. Let's walk through a simple configuration for the event-service as an example.
|
|
52
|
+
|
|
53
|
+
**To add an event definition**
|
|
54
|
+
|
|
55
|
+
1. Select _Services_ -> _Events_ in the navigation menu.
|
|
56
|
+
2. Select the _Definitions_ tab in this view and you will see a list of system defined events.
|
|
57
|
+
3. Click _Add definition_ to initiate creation of a new event definition.
|
|
58
|
+
4. In the create dialog, enter the namespace and name of your event, then click _Save_
|
|
59
|
+
5. Your new event definition will be shown under its namespace; use the edit icon to modify it.
|
|
60
|
+
|
|
61
|
+
## Using a service API
|
|
62
|
+
|
|
63
|
+
Once you have an event definition configured, you can use the event service API to send events of this definition.
|
|
64
|
+
|
|
65
|
+
**To create a service account**
|
|
66
|
+
|
|
67
|
+
1. In Keycloak realm administration, from _Clients_, click _Create client_ to create a client to use with a service account.
|
|
68
|
+
2. Set the _Client Type_ to "Confidential", enter a _Client ID_ (e.g., `urn:ads:platform:event-service` for event service).
|
|
69
|
+
3. Under _Client authentication_, toggle _Client authentication_ to **On**.
|
|
70
|
+
4. Under _Authentication flow_, toggle _Service accounts_ to **On**.
|
|
71
|
+
5. Set _Valid redirect URIs_ to https://api.adsp.alberta.ca and _Web origins_ to +.
|
|
72
|
+
6. Save the client configuration.
|
|
73
|
+
7. Navigate to the _Service account roles_ tab
|
|
74
|
+
8. Click _Assign role_, filter by clients, select `urn:ads:platform:event-service`, and assign the `event-sender` role.
|
|
75
|
+
9. Select the _Credentials_ tab and take note of the _Client secret_.
|
|
76
|
+
|
|
77
|
+
**To send an event manually**
|
|
78
|
+
|
|
79
|
+
1. In tenant administration, from the _Services_ -> _Events_ view, click the _Read the API docs_ link in the aside (either on the right or the bottom).
|
|
80
|
+
2. In API documentation, click _Authorize_, and login using `client_credentials` grant with the client created above.
|
|
81
|
+
3. Expand the _POST /event/v1/events_ endpoint, click _Try it out_.
|
|
82
|
+
4. In the _Request body_ text field, set the namespace and name of the event to match your definition and the timestamp to an ISO2601 timestamp (e.g. 2021-10-02T12:00:00Z).
|
|
83
|
+
5. Click _Execute_ to send the request.
|
|
84
|
+
|
|
85
|
+
**To send an event from your application**
|
|
86
|
+
|
|
87
|
+
1. Get an access token with the event-sender role.
|
|
88
|
+
```typescript
|
|
89
|
+
const { access_token } = await fetch(`${keycloakRealmTokenUrl}`, {
|
|
90
|
+
method: 'POST',
|
|
91
|
+
headers: {
|
|
92
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
93
|
+
},
|
|
94
|
+
body: new URLSearchParams({
|
|
95
|
+
client_id: clientId,
|
|
96
|
+
client_secret: clientSecret,
|
|
97
|
+
grant_type: 'client_credentials',
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
2. Send the event via the event service.
|
|
102
|
+
```typescript
|
|
103
|
+
await fetch(`${eventServiceUrl}`, {
|
|
104
|
+
method: 'POST',
|
|
105
|
+
headers: {
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
Authorization: `Bearer ${access_token}`,
|
|
108
|
+
},
|
|
109
|
+
body: JSON.stringify({
|
|
110
|
+
namespace,
|
|
111
|
+
name,
|
|
112
|
+
timestamp: new Date(),
|
|
113
|
+
payload,
|
|
114
|
+
}),
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This is how you can send an event in ADSP. Other services are configured and accessed via API in similar ways.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Important notes
|
|
4
|
+
nav_order: 2
|
|
5
|
+
---
|
|
6
|
+
# Important notes
|
|
7
|
+
## Configuration caching
|
|
8
|
+
ADSP consists of interconnected micro-services. Caching is used extensively to limit synchronous coupling and chatter between services.
|
|
9
|
+
|
|
10
|
+
Configuration service is used by multiple platform services to store relatively static configuration. Platform services cache their configuration with a long TTL and use configuration events for cache invalidation. In practice, this means that configuration changed within tenant administration may not immediately be applied, but should catch up once any stale cache entry is invalidated.
|
|
11
|
+
|
|
12
|
+
## Open API site and client credentials
|
|
13
|
+
ADSP includes a Swagger UI based [API documentation site](https://api.adsp.alberta.ca) that includes tenant specific OpenID Connect configuration for authorizing requests. When using 'Try it out' from this site, the requests are made from the frontend and so the realm configuration must include this site in Web Origins (for CORS) and in Redirect URLs if using a frontend flow. Tenant realms are created with a `api-app-client` client that can be used with authorization code sign in; enable the client to use it.
|
|
14
|
+
|
|
15
|
+
## Access management
|
|
16
|
+
ADSP capabilities are provided by micro-services that recognize and accept your tenant realm's access tokens. This means that the tenant realm administrators can grant platform service specific permissions to any user or service accounts in their realm.
|
|
17
|
+
|
|
18
|
+
The platform service roles are automatically included as *Client Roles* when your tenant realm is created. They can be found under the bearer-only *Clients* with a naming convention of: `urn:ads:platform:{x-service}`.
|
|
19
|
+
|
|
20
|
+
**To see some of these clients**
|
|
21
|
+
1. From Keycloak realm administration, select *Clients* and find the clients with the above naming convention.
|
|
22
|
+
2. Select one of these clients and the *Roles* tab to see associated roles.
|
|
23
|
+
|
|
24
|
+
New platform roles are introduced as new platform services are added, and tenants can review and add them from the tenant administration in the Service roles tab of Access service.
|
|
25
|
+
|
|
26
|
+
### Token audience
|
|
27
|
+
|
|
28
|
+
Platform services verify the token signature and verify that the service client ID is included in the `audience`. When using the pre-populated client roles with the base realm configuration, the client ID is automatically resolved and included in the token; this is handled by the *Audience Resolve* protocol mapper included in the *roles* scope. However, if you are using the configurable access capabilities of some services (e.g. `task-service` queue `workerRoles`), then you must configure the client that retrieves the token to include the target platform service in the audience with an *Audience Mapper*.
|
|
29
|
+
|
|
30
|
+
**To add to audience**
|
|
31
|
+
1. Go to *Client scopes* in the left sidebar.
|
|
32
|
+
2. Click *Create client scope*.
|
|
33
|
+
3. Enter a *Name* (e.g., `api-audience`) and *Description*. Leave *Protocol* as `openid-connect`. Click *Save*.
|
|
34
|
+
4. With your new scope selected, go to the *Mappers* tab.
|
|
35
|
+
5. Click *Add mapper* and select *By configuration*.
|
|
36
|
+
6. Choose **Audience** from the built-in mapper types.
|
|
37
|
+
7. In the mapper configuration:
|
|
38
|
+
- **Name**: Enter a descriptive name (e.g., `audience-mapper`)
|
|
39
|
+
- **Included Client** (optional): Enter the client ID of the service that will consume the token
|
|
40
|
+
- **Included Custom Audience**: Enter the audience value (e.g., `urn:ads:platform:task-service`)
|
|
41
|
+
- **Add to ID token**: Off (or On if needed)
|
|
42
|
+
- **Add to access token**: **On**
|
|
43
|
+
8. Click *Save*.
|
|
44
|
+
9. Go to *Clients* and select the application that needs the token.
|
|
45
|
+
10. Click the *Client scopes* tab.
|
|
46
|
+
11. Click *Add client scope* and select your `api-audience` scope.
|
|
47
|
+
12. Choose **Default** (always added) or **Optional** (only added when requested in scope parameter).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Feel free to add content and custom Front Matter to this file.
|
|
3
|
+
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
|
|
4
|
+
|
|
5
|
+
layout: home
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Alberta Digital Service Platform (ADSP) is a collection of capabilities with a unified model for tenancy and administration. This is a guide to developing applications on ADSP. It is written for developers and people with an understanding of technical concepts like APIs and access tokens.
|
|
9
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Platform deployment
|
|
4
|
+
nav_order: 7
|
|
5
|
+
parent: Platform development
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Platform deployment
|
|
9
|
+
|
|
10
|
+
TODO:This should be captured in scripts for automated setup.
|
|
11
|
+
|
|
12
|
+
This repository includes manifests for deployment in OpenShift under `/.openshift`. The micro-services
|
|
13
|
+
communicate over APIs and RabbitMQ, and so deployment into other hosting environments is also possible.
|
|
14
|
+
|
|
15
|
+
## Prerequisites
|
|
16
|
+
|
|
17
|
+
<!-- tags: [keycloak] -->
|
|
18
|
+
A few prerequisites are needed to set up an ADSP deployment:
|
|
19
|
+
|
|
20
|
+
1. [Keycloak](https://www.keycloak.org/) is used as an IAM solution. Realms provide tenants with user access management under their own administrative control.
|
|
21
|
+
2. [RabbitMQ](https://www.rabbitmq.com/) is used as a messaging framework and work queue in some platform services.
|
|
22
|
+
3. Databases for platform micro-services. Containerized databases are not included in the deployment manifests, and managed options are recommended.
|
|
23
|
+
|
|
24
|
+
## Keycloak configuration
|
|
25
|
+
|
|
26
|
+
<!-- tags: [keycloak] -->
|
|
27
|
+
|
|
28
|
+
### Master realm configuration
|
|
29
|
+
|
|
30
|
+
The tenant service creates realms for new tenants using a service account.
|
|
31
|
+
|
|
32
|
+
1. Create a confidential client with a service account.
|
|
33
|
+
2. Grant the service account role(s) to create and modify realms.
|
|
34
|
+
|
|
35
|
+
### Core realm configuration
|
|
36
|
+
|
|
37
|
+
Platform micro-services make requests under a non-tenant 'core' context. This is handled with a 'core' realm in Keycloak.
|
|
38
|
+
|
|
39
|
+
1. Create a 'core' realm in Keycloak.
|
|
40
|
+
2. Create public *client* with *Standard Flow* enabled for tenant administration application: `urn:ads:platform:tenant-admin-app`.
|
|
41
|
+
3. Create confidential *clients* with service accounts for `urn:ads:platform:subscriber-gateway` and `urn:ads:platform:api-docs-app`.
|
|
42
|
+
4. Create confidential *clients* with service accounts for backend micro-services including:
|
|
43
|
+
- `urn:ads:platform:tenant-service`
|
|
44
|
+
- `urn:ads:platform:event-service`
|
|
45
|
+
- `urn:ads:platform:value-service`
|
|
46
|
+
- ...
|
|
47
|
+
5. Create service *client roles*:
|
|
48
|
+
- In `urn:ads:platform:value-service`, create `value-reader` and `value-writer` roles.
|
|
49
|
+
- In `urn:ads:platform:event-service`, create `event-sender` role.
|
|
50
|
+
- In `urn:ads:platform:configuration-service`, create `configured-service` role.
|
|
51
|
+
- In `urn:ads:platform:notification-service`, create `subscription-app` role.
|
|
52
|
+
- In `urn:ads:platform:verify-service`, create `code-generator` and `code-verifier` roles.
|
|
53
|
+
- In `urn:ads:platform:tenant-service`, create `platform-service` role, enable *composite roles*, and add `event-sender` and `configured-service` client roles from above.
|
|
54
|
+
6. Assign roles to *clients*
|
|
55
|
+
- Grant the service accounts the `platform-service` role.
|
|
56
|
+
- Grant `urn:ads:platform:event-service` the `value-writer` role.
|
|
57
|
+
- Grant `urn:ads:platform:notification-service` the `code-generator` and `code-verifier` roles.
|
|
58
|
+
- Grant `urn:ads:platform:subscriber-gateway` and `urn:ads:platform:form-service` the `subscription-app` role.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## RabbitMQ configuration
|
|
62
|
+
Some platform services communicate over RabbitMQ. The exchange and queue configuration required is contained in the code, but manual configuration is necessary to create the accounts. All accounts should access a common vhost in RabbitMQ.
|
|
63
|
+
|
|
64
|
+
1. Create accounts for platform services including:
|
|
65
|
+
- event-service
|
|
66
|
+
- notification-service
|
|
67
|
+
- push-service
|
|
68
|
+
- file-service
|
|
69
|
+
|
|
70
|
+
Additional services can be modified to use RabbitMQ for configuration cache invalidation.
|
|
71
|
+
|
|
72
|
+
## OpenShift configuration
|
|
73
|
+
|
|
74
|
+
References for configuration in the form of ConfigMaps and Secrets are included in the `/.openshift/configuration` directory. These resources need to be manually created within the environment with configuration values. Other deployment resources are contained in templates under the `/.openshift/managed` directory and are automatically applied by the `deliver-ci` workflow.
|
|
75
|
+
|
|
76
|
+
1. Create projects for 'build', 'dev', 'uat', and 'prod' environments in OpenShift.
|
|
77
|
+
2. Set appropriate values in the ConfigMaps and Secrets and apply to environments.
|
|
78
|
+
3. Create a service account in 'build' with edit permission to other projects for the pipeline.
|
|
79
|
+
4. Process and apply managed templates, and/or set service account token in GitHub for the pipeline.
|
|
80
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
layout: page
|
|
3
|
+
title: Getting started
|
|
4
|
+
nav_order: 1
|
|
5
|
+
parent: Platform development
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Getting started
|
|
9
|
+
|
|
10
|
+
## Project structure
|
|
11
|
+
|
|
12
|
+
ADSP repository is a monorepo using [Nx](https://github.com/nrwl/nx).
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
adsp-monorepo
|
|
16
|
+
├── .compose
|
|
17
|
+
├── .openshift
|
|
18
|
+
└── apps
|
|
19
|
+
├── api-docs-app
|
|
20
|
+
└── ...
|
|
21
|
+
├── docs
|
|
22
|
+
└── libs
|
|
23
|
+
├── adsp-service-sdk
|
|
24
|
+
└── core-common
|
|
25
|
+
└── tests
|
|
26
|
+
└── tools
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Specific deployable frontend applications and backend services can be found under the `apps` folder and libraries of common modules can be found under the `libs` folder. The `.compose` and `.openshift` folders contain deployment manifests for docker compose and OpenShift. The `tests` folder contains artillery load test scenarios, the `tools` folder contains workspace templates, and the `docs` folder contains GitHub Pages content including this guide.
|
|
30
|
+
|
|
31
|
+
## Building sub-projects
|
|
32
|
+
The monorepo uses a common `package.json` across all sub-projects. Start by installing the dependencies including development dependencies.
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm i -D
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Build (or run other targets) against specific sub-projects using:
|
|
39
|
+
```bash
|
|
40
|
+
npx nx build api-docs-app
|
|
41
|
+
npx nx test api-docs-app --code-coverage
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Build sub-projects affected by current changes using the `nx affected` commands like:
|
|
45
|
+
```bash
|
|
46
|
+
npx nx affected --target build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuring local environment
|
|
50
|
+
Backend services make use of the `dotenv` library and local environment can be configured by creating a `.env` file under the sub-project root folder.
|
|
51
|
+
|
|
52
|
+
Frontend applications retrieve configuration as a json document from the server. Locally this can be handled via the webpack development server proxy configuration. Refer to the `proxy.conf.json` file under the sub-project.
|
|
53
|
+
|
|
54
|
+
## Running in Docker compose
|
|
55
|
+
Manifests for running the services in docker compose can be found under the `.compose` folder. They are split across multiple files so that a subset of services can be run.
|
|
56
|
+
|
|
57
|
+
The backend services use a common base docker container image that includes npm dependencies to streamline local workflow. Build the base service in `.compose/docker-compose.infra.yml` to create this base image.
|
|
58
|
+
|
|
59
|
+
```base
|
|
60
|
+
docker-compose build base -f .compose/docker-compose.infra.yml
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Run a set of components using:
|
|
64
|
+
```bash
|
|
65
|
+
docker-compose up -f .compose/docker-compose.infra.yml -f .compose/docker-compose.value.yml -f .compose/docker-compose.event.yml
|
|
66
|
+
```
|