FAQ | This is a LIVE service | Changelog

card-management-system.md 12.8 KB
Newer Older
1
2
3
4
5
# Card Management System

This page gives an overview of the Card Management System, describing its current status, where and
how it's developed and deployed, and who is responsible for maintaining it.

6
7
!!! warning
    This service as a whole is currently in active development and at **beta stability**.
8
9
10
11
12
13
14
15
16
17

## Service Description

The Card Management System is a replacement for the existing
[legacy card database](./legacy-card-db.md). The Card Management System will allow the management
of university cards - from the creation and printing of university cards, through to the export
of data for use by downstream systems.

## Service Status

18
19
The Card Management System as a whole is currently in `beta`, with many of the components of the
service under active development. Details of the project can be found within the
20
21
22
23
[project page on the UIS site](https://www.uis.cam.ac.uk/it-portfolios/projects/card-system-replacement).

## Contact

24
25
Technical queries and support should be directed to
[universitycard-dev@uis.cam.ac.uk](mailto:universitycard-dev@uis.cam.ac.uk) and will be picked up
26
by a member of the team working on the service. To ensure that you receive a response, always
27
28
direct requests to [universitycard-dev@uis.cam.ac.uk](mailto:universitycard-dev@uis.cam.ac.uk)
rather than reaching out to team members directly.
29
30
31
32
33
34
35

Queries about the project or functionality of the Card Management System should be raised as
[GitLab issues in the feedback repository](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/feedback).

Technical questions or problems with the Card API should be raised as
[GitLab issues in the Card API repository](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-api).

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Queries about data or operational issues such as card replacements should be directed to the card
office at [universitycard@admin.cam.ac.uk](mailto:universitycard@admin.cam.ac.uk).


## Architecture

The Card Management system is made up of the following components:

* [The Card Frontend](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-frontend) -
    a React-based frontend application used by card representatives and card office staff to
    view card details, print cards, and in future order new cards and revoke existing cards.
* [The Printer Client](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/printer-client) -
    a Python and Java CLI application which interfaces with the Card API to allow cards to be
    printed by the card office, making use of a wrapper around the SDK for the Zebra Series 7
    printers currently in use for card printing.
* [The Card Client](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-client) -
    a Python CLI to allow export of card details for institutions across the University, mainly
    used to populate access systems which require a CSV feed of active card details.
* [The Card API](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-api) -
    a Django application which acts as our single source of truth for card details, allowing
    querying of card data, printing of cards, raising card requests and revoking cards.
* [The Photo API](https://gitlab.developers.cam.ac.uk/uis/devops/iam/identity-photos-service/photo-api) -
    a Django application which acts as our single source of truth for 'approved' photos of members
    of the University, used to fetch photos which appear on University cards.
* [Card Sync Tool](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/sync-tool) -
    a Python CLI tool which is used to sync card and photo data from the
    [legacy card database](./legacy-card-db.md) to the Card and Photo APIs.

All components are deployed to GCP within the
[Identity Platform Deployment](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity)
project. The [Card Sync Tool](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/sync-tool)
is run on a
[GitLab Scheduled pipeline](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/pipeline_schedules)
defined under the
[`legacy_data_sync`](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/tree/master/legacy_data_sync)
directory.

## Deployment

| Environment Name | Component     | URL                                                     |
| ---------------- | ------------- | ------------------------------------------------------- |
| Production       | Card Frontend | https://card.apps.cam.ac.uk                             |
| Production       | Card API      | https://api.apps.cam.ac.uk/card/                        |
| Production       | Photo API     | https://api.apps.cam.ac.uk/photo/                       |
| Staging          | Card Frontend | https://card-frontend.test.identity.gcp.uis.cam.ac.uk/  |
| Staging          | Card API      | https://api.apps.cam.ac.uk/card-test/                   |
| Staging          | Photo API     | https://api.apps.cam.ac.uk/photo-test/                  |
| Development      | Card Frontend | https://card-frontend.devel.identity.gcp.uis.cam.ac.uk/ |
| Development      | Card API      | https://api.apps.cam.ac.uk/card-dev/                    |
| Development      | Photo API     | https://api.apps.cam.ac.uk/photo-dev/                   |

API documentation for the production version of the Card API and Photo API can be found on the API
Gateway's developer portal:

 *  [Card API documentation](https://developer.api.apps.cam.ac.uk/docs/card/1/overview),
 *  [Photo API documentation](https://developer.api.apps.cam.ac.uk/docs/photo/1/overview),

Currently the `Production` instances of the Photo and Card API sync data from the `CARD`
[legacy card database](./legacy-card-db.md). The `Staging` instances of the Photo and Card API
sync data from the development `CARD_T` Oracle database, and the `Development` instances sync
a limited set of data from the `CARD_T` Oracle database. The frequency of data sync is defined
by the sync configuration held within the
98
99
100
101
102
103
104
105
[deployment project](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/blob/master/legacy_data_sync.tf#L3).

## Technologies used

The following gives an overview of the technologies the Card Management System is built on.

| Category | Language | Primary framework |
| -------- | -------- | --------- |
106
107
| Card Frontend | TypeScript | React |
| Printer Client | Python / Java | pyscard / Zebra Printer SDK |
108
| Card Client | Python | Requests |
109
110
| Card API | Python | Django |
| Photo API | Python | Django |
111
112
113
114
115
116
117
118
119
120
| Sync Tool | Python | Oracle_cx |

## Operational documentation

The following gives an overview of how the Card Management System is deployed and maintained.

### How and where the Card Management System is deployed

The infrastructure for the Card Management System is deployed through the Terraform defined
within the [Deploy Identity](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity)
121
122
project. The Card API, Photo API and Card Frontend are deployed via GitLab pipelines, and will be
automatically deployed to staging on the success of each master pipeline
123
124
125
126
127
128
129
130
131
132
([see pipeline configuration here](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-api/-/blob/master/.gitlab-ci.yml#L26.)),
with production deployment a manual step in the pipeline once staging has succeeded.

### Deploying a new release

Deploying any infrastructure changes can be completed using
[Logan](https://gitlab.developers.cam.ac.uk/uis/devops/tools/logan)
as described within the
[Deploy Identity project's readme](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/blob/master/README.md).

133
134
135
136
Deploying a new release of the Card API, Photo API or card frontend to staging and then production
can be completed by running the
[master pipeline](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-api/-/pipelines)
within the project's repo. Changes must be tested in staging before deploying to production.
137
138
139

### Monitoring

140
The Card API, Photo API and Card Frontend make use of our
141
142
[GCP site monitoring module](https://gitlab.developers.cam.ac.uk/uis/devops/infra/terraform/gcp-site-monitoring)
for monitoring of the production environment. This will send an alert to
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
devops-alarms@uis.cam.ac.uk if any of the deployments have non-transient uptime check failures.


### Authentication and Authorization

The card management system enforces authentication and authorization using a number of different
methods.

#### Service-to-service Card and Photo API authorization

The [Card](https://developer.api.apps.cam.ac.uk/docs/card/1/overview) and
[Photo](https://developer.api.apps.cam.ac.uk/docs/photo/1/overview) allow users of the API Gateway
to request access to the API backends. Granting access to an application within the API Gateway
will allow an application to query the APIs, but will only allow them to see entities that they
own - i.e. photos or cards which are attached to the identifier given to that application within
the API Gateway. This will likely mean that they will not be able to see any cards or photos. See
`Card and Photo API permission model` below to determine how to grant wider access to applications.

!!! important
    The API Gateway is only used for authentication for the Card and Photo APIs and therefore
    allowing an application to access either API does not imply that this application can access
    or make changes to any card records.

#### End-user authentication in the Card Frontend

The [Card Frontend](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-frontend)
authenticates uses against the API Gateway using the
[Auth Code with PKCE flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-proof-key-for-code-exchange-pkce).
This allows the API Gateway to identify the individual who is using the Card Frontend and pass
this information to the Card and Photo APIs. This also allows the Card Frontend to use the identity
token provided by the API Gateway to display basic information about the user. The code which
handles the authentication flow can be found
[here](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-frontend/-/blob/main/src/api-gateway/api-gateway-service.ts).

#### Card and Photo API permissions model

The Card and Photo API's permissions models rely on a specification which documents the
applications, people or groups of people who are granted certain levels of access. Both
permissions specifications can be found in the deploy identity project:

* [Card permissions spec](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/blob/master/card_permissions.tf),
* [Photo permissions spec](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity/-/blob/master/photo_permissions.tf),

The most commonly granted permission are `CARD_DATA_READER` for the Card API and `PHOTO_VIEWER`
for the Photo API, which allow a person or application to view all cards and all photos. These
permissions should only be granted to applications registered by institutional staff, computer
officers or other IT staff.

The permissions specifications are updated using terraform in the same way as any other part of the
infrastructure, as documented in the
[deployment project](https://gitlab.developers.cam.ac.uk/uis/devops/iam/deploy-identity#bootstrapping)
194

195
#### Card Frontend permissions model
196

197
198
199
200
201
202
The Card Frontend honours the permissions model enforced by the Card and Photo APIs by only
displaying relevant actions to users with a given permission
(e.g. [hiding the 'queue for printing' button if the user is not able to create cards](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-frontend/blob/main/src/card-requests/CardRequestPage.tsx#L673).
Additionally, the Card Frontend currently requires that all users have the
[`CARD_DATA_READER` permission](https://gitlab.developers.cam.ac.uk/uis/devops/iam/card-database/card-frontend/blob/main/src/admin-layout/CardAdminLayout.tsx#L27),
without this permission a user is shown an error screen informing them that do not have access.
203
204
205
206
207
208
209
210
211
212
213
214

## Additional documentation

Information about the overall architecture of the new Card Management System can be found
[within the wiki page for the identity project](https://gitlab.developers.cam.ac.uk/uis/devops/iam/documentation/-/wikis/card/Architecture).

## Service Management and tech lead

The **service owner** for the Card Management System is **currently vacant**.

The **service manager** for the Card Management System is **currently vacant**.

215
The **tech lead** for the Card Management System is [Andrew Vella](https://www.lookup.cam.ac.uk/person/crsid/av603).
216
217
218
219
220

The following engineers have operational experience with the Card Management System and are able to
respond to support requests or incidents:

* [Robin Goodall](https://www.lookup.cam.ac.uk/person/crsid/rjg21)
221
* [Sam Wenham](https://www.lookup.cam.ac.uk/person/crsid/sdw37)
222
* [Dave Hart](https://www.lookup.cam.ac.uk/person/crsid/dkh21)