Skip to content

Commit c8d576d

Browse files
committed
feat: add auth to openapi
1 parent a0daa4c commit c8d576d

File tree

7 files changed

+81
-21
lines changed

7 files changed

+81
-21
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
NEXT_PUBLIC_PROXY_URL=http://localhost:8787
1+
NEXT_PUBLIC_PROXY_URL=https://classcharts-proxy.veloi.workers.dev
22
NEXT_PUBLIC_ALGOLIA_APP_ID=L0EAOEJCCQ
33
NEXT_PUBLIC_ALGOLIA_INDEX=docs_index
44
NEXT_PUBLIC_ALGOLIA_API_KEY=30fe2c1027197e7f8df72f43f2c655ea

content/docs/authentication.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You'll need to login first, you can do this through the `/login` endpoint for yo
2727

2828
With each request you must specify your authentication token in the `authorization` header, and optionally your student ID in the URL. However, it is **required** to specify student ID when using the parent API, as ClassCharts needs to know which student you would like to get data for.
2929

30-
E.g. `/apiv2student/activity/2339528` with the header: `Authorization: Basic 5vf2v7n5uk9jftrxaarrik39vk6yjm48`.
30+
E.g. `/apiv2student/activity/2339528` with the header: `Authorization: Basic eW91IHNob3VsZCBzdGFyIHRoaXMgcmVwbyE`.
3131

3232
## Retaining a session
3333

content/docs/parent-api/ping.mdx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
title: Parent Ping
33
description: >
44
Gets basic information about the logged in parent and what access they have.
5+
56
This endpoint is also used for revalidating your session id (authentication
67
token).
7-
8-
To get your new authentication token, call the endpoint, and use the token in
9-
the returned body (`body.meta.session_id`) as your new authentication token.
10-
11-
12-
Access tokens should be refreshed every 180 seconds.
138
full: true
149
_openapi:
1510
method: POST
@@ -20,15 +15,10 @@ _openapi:
2015
contents:
2116
- content: >
2217
Gets basic information about the logged in parent and what access they
23-
have. This endpoint is also used for revalidating your session id
24-
(authentication token).
25-
26-
To get your new authentication token, call the endpoint, and use the
27-
token in the returned body (`body.meta.session_id`) as your new
28-
authentication token.
18+
have.
2919
30-
31-
Access tokens should be refreshed every 180 seconds.
20+
This endpoint is also used for revalidating your session id
21+
(authentication token).
3222
---
3323

3424
<APIPage document={"./openapi/parentclientapi.yaml"} operations={[{"path":"/ping","method":"post"}]} hasHead={false} />

openapi/clientapi.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ servers:
99
- url: https://www.classcharts.com/apiv2parent
1010
description: Parent API
1111

12+
components:
13+
securitySchemes:
14+
basic_auth:
15+
$ref: "./schemas/auth/basic_auth.yaml#/basic_auth"
16+
1217
paths:
1318
/behaviour/{studentId}:
1419
get:
1520
operationId: list-behaviour
1621
summary: List Behaviour
22+
security:
23+
- basic_auth: []
1724
description: Gets the student's behaviour.
1825
parameters:
1926
- name: studentId
@@ -62,6 +69,8 @@ paths:
6269
get:
6370
operationId: list-activity
6471
summary: List Activity
72+
security:
73+
- basic_auth: []
6574
description: >
6675
The `from` field does not work as you would expect, since this endpoint is meant for pagination on the home page, Classcharts only returns a 50 points from the `to` field.
6776
@@ -120,6 +129,8 @@ paths:
120129
operationId: list-homeworks
121130
summary: List Homeworks
122131
description: Gets the student's homeworks
132+
security:
133+
- basic_auth: []
123134

124135
parameters:
125136
- name: studentId
@@ -178,6 +189,8 @@ paths:
178189
operationId: list-classes
179190
summary: List Classes
180191
description: Lists the student's classes
192+
security:
193+
- basic_auth: []
181194
parameters:
182195
- name: studentId
183196
in: path
@@ -203,6 +216,8 @@ paths:
203216
operationId: list-lessons
204217
summary: List Lessons
205218
description: Gets the student's lessons for a given date
219+
security:
220+
- basic_auth: []
206221
parameters:
207222
- name: studentId
208223
in: path
@@ -246,6 +261,8 @@ paths:
246261
operationId: list-badges
247262
summary: List Badges
248263
description: Gets the student's earned badges
264+
security:
265+
- basic_auth: []
249266
parameters:
250267
- name: studentId
251268
in: path
@@ -281,6 +298,8 @@ paths:
281298
operationId: list-announcements
282299
summary: List Announcements
283300
description: Gets the student's announcements
301+
security:
302+
- basic_auth: []
284303
parameters:
285304
- name: studentId
286305
in: path
@@ -316,6 +335,8 @@ paths:
316335
operationId: list-detentions
317336
summary: List Detentions
318337
description: Gets the student's detentions
338+
security:
339+
- basic_auth: []
319340
parameters:
320341
- name: studentId
321342
in: path
@@ -351,6 +372,8 @@ paths:
351372
operationId: get-attendance
352373
summary: List Attendance
353374
description: Gets the student's attendance
375+
security:
376+
- basic_auth: []
354377
parameters:
355378
- name: studentId
356379
in: path
@@ -396,6 +419,8 @@ paths:
396419
operationId: list-pupil-fields
397420
summary: List Pupil Fields
398421
description: Gets the student's pupil fields
422+
security:
423+
- basic_auth: []
399424
parameters:
400425
- name: studentId
401426
in: path
@@ -431,6 +456,8 @@ paths:
431456
operationId: list-academic-reports
432457
summary: List Academic Reports
433458
description: Get list of academic reports
459+
security:
460+
- basic_auth: []
434461
parameters:
435462
- name: studentId
436463
in: query
@@ -456,6 +483,8 @@ paths:
456483
operationId: get-academic-report
457484
summary: Get Academic Report
458485
description: Get academic report by ID
486+
security:
487+
- basic_auth: []
459488
parameters:
460489
- name: studentId
461490
in: query
@@ -487,6 +516,8 @@ paths:
487516
operationId: list-on-report-cards
488517
summary: List On Report Cards
489518
description: Get list of on report cards
519+
security:
520+
- basic_auth: []
490521
parameters:
491522
- name: pupil_id
492523
in: query
@@ -511,6 +542,8 @@ paths:
511542
operationId: get-on-report-card
512543
summary: Get On Report Card
513544
description: Get on report card by ID
545+
security:
546+
- basic_auth: []
514547
parameters:
515548
- name: pupil_id
516549
in: query
@@ -542,6 +575,8 @@ paths:
542575
operationId: get-on-report-card-summary-comment
543576
summary: Get On Report Card Summary Comment
544577
description: Get on report card summary comment by date
578+
security:
579+
- basic_auth: []
545580
parameters:
546581
- name: pupil_id
547582
in: query
@@ -577,6 +612,8 @@ paths:
577612
operationId: get-on-report-card-target
578613
summary: Get On Report Card Target
579614
description: Get on report card target
615+
security:
616+
- basic_auth: []
580617
parameters:
581618
- name: pupil_id
582619
in: query

openapi/parentclientapi.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ servers:
77
- url: https://www.classcharts.com/apiv2parent
88
description: Parent API
99

10+
components:
11+
securitySchemes:
12+
basic_auth:
13+
$ref: "./schemas/auth/basic_auth.yaml#/basic_auth"
14+
1015
paths:
1116
/ping:
1217
post:
1318
operationId: ping
1419
summary: Parent Ping
1520
description: >
1621
Gets basic information about the logged in parent and what access they have.
17-
This endpoint is also used for revalidating your session id (authentication token).
18-
19-
To get your new authentication token, call the endpoint, and use the token in the returned body (`body.meta.session_id`) as your new authentication token.
2022
21-
22-
Access tokens should be refreshed every 180 seconds.
23+
This endpoint is also used for revalidating your session id (authentication token).
24+
security:
25+
- basic_auth: []
2326

2427
requestBody:
2528
content:
@@ -55,6 +58,8 @@ paths:
5558
operationId: list-pupils
5659
summary: List Pupils
5760
description: Get a list of pupils connected to this parent's account
61+
security:
62+
- basic_auth: []
5863
responses:
5964
"200":
6065
description: Array of pupils
@@ -85,6 +90,8 @@ paths:
8590
summary: List Parent Behaviour
8691
description: >
8792
Lists the behaviour points for a pupil.
93+
security:
94+
- basic_auth: []
8895
parameters:
8996
- name: studentId
9097
in: path
@@ -111,6 +118,8 @@ paths:
111118
summary: Delete Parent Behaviour Point
112119
description: >
113120
Delets a behaviour point from a pupil's record.
121+
security:
122+
- basic_auth: []
114123
requestBody:
115124
required: true
116125
content:
@@ -143,6 +152,8 @@ paths:
143152
summary: Add Parent Behaviour Point
144153
description: >
145154
Adds a behaviour point to a pupil's record.
155+
security:
156+
- basic_auth: []
146157
requestBody:
147158
required: true
148159
content:
@@ -205,6 +216,8 @@ paths:
205216
operationId: change-password
206217
summary: Change Password
207218
description: Changes the login password for the current parent account
219+
security:
220+
- basic_auth: []
208221
requestBody:
209222
required: true
210223
content:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
basic_auth:
2+
type: http
3+
scheme: basic
4+
description: >
5+
This is the `session_id` returned when logging in. e.g. `Basic eW91IHNob3VsZCBzdGFyIHRoaXMgcmVwbyE=`

openapi/studentclientapi.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ servers:
77
- url: https://www.classcharts.com/apiv2student
88
description: Student API
99

10+
components:
11+
securitySchemes:
12+
basic_auth:
13+
$ref: "./schemas/auth/basic_auth.yaml#/basic_auth"
14+
1015
paths:
1116
/ping:
1217
post:
@@ -16,6 +21,8 @@ paths:
1621
Gets basic information about the logged in student and what access they have.
1722
1823
This endpoint is also used for revalidating your session id (authentication token).
24+
security:
25+
- basic_auth: []
1926

2027
requestBody:
2128
content:
@@ -78,6 +85,8 @@ paths:
7885
operationId: list-rewards
7986
summary: List Rewards
8087
description: Gets the available items in the student's rewards shop.
88+
security:
89+
- basic_auth: []
8190
parameters:
8291
- name: studentId
8392
in: path
@@ -113,6 +122,8 @@ paths:
113122
operationId: purchase-reward
114123
summary: Purchase Reward
115124
description: Purchase a reward item from the student's rewards shop.
125+
security:
126+
- basic_auth: []
116127
parameters:
117128
- name: itemId
118129
in: path
@@ -157,6 +168,8 @@ paths:
157168
operationId: tick-homework
158169
summary: Tick Homework
159170
description: Toggle the status of a homework item to 'completed'.
171+
security:
172+
- basic_auth: []
160173

161174
parameters:
162175
- name: studentId
@@ -190,6 +203,8 @@ paths:
190203
operationId: get-student-code
191204
summary: Get Student Code
192205
description: Gets the student's student code
206+
security:
207+
- basic_auth: []
193208
requestBody:
194209
required: true
195210
content:

0 commit comments

Comments
 (0)