fleet/website/api
Roberto Dip d98e1ecf27
allow to customize the signed CSR return type (#19213)
for #19027, this modifies the website to accept an `deliveryMethod` parameter to
respond with the signed CSR instead of delivering an email.

The current approach also maintains backwards compatibility:

**Response without `deliveryMethod` (unchanged except for custom headers)**

```
$ curl --insecure -v -H 'content-type: application/json' http://localhost:2024/api/v1/deliver-apple-csr -d '{"unsignedCsrData": "foo"}'
*   Trying [::1]:2024...
* Connected to localhost (::1) port 2024
> POST /api/v1/deliver-apple-csr HTTP/1.1
> Host: localhost:2024
> User-Agent: curl/8.4.0
> Accept: */*
> content-type: application/json
> Content-Length: 26
>
< HTTP/1.1 200 OK
< X-Powered-By: Sails <sailsjs.com>
< Cache-Control: no-cache, no-store
< X-Exit: success
< X-Exit-Description: Delivered email to specified email address with certificate signing request attached.
< Content-Type: text/plain; charset=utf-8
< Content-Length: 2
< ETag: W/"2-nOO9QiTIwXgNtWtBJezz8kv3SLc"
< Set-Cookie: sails.sid=s%3AqOZoNKY2CCZ6PFb9fIKaAjtiTKjB7Gum.9jodWIUG6DCNnXu%2Bn%2BF8cJmI%2Fn19Tk%2FdIkDPBl%2BILbI; Path=/; HttpOnly
< Date: Wed, 22 May 2024 18:23:16 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
* Connection #0 to host localhost left intact
OK
```

**Response with `deliveryMethod=json`**

```
$ curl --insecure -v -H 'content-type: application/json' http://localhost:2024/api/v1/deliver-apple-csr?deliveryMethod=json -d '{"unsignedCsrData": "foo"}'
*   Trying [::1]:2024...
* Connected to localhost (::1) port 2024
> POST /api/v1/deliver-apple-csr?alt=json HTTP/1.1
> Host: localhost:2024
> User-Agent: curl/8.4.0
> Accept: */*
> content-type: application/json
> Content-Length: 26
>
< HTTP/1.1 200 OK
< X-Powered-By: Sails <sailsjs.com>
< Cache-Control: no-cache, no-store
< Content-Type: application/json; charset=utf-8
< X-Exit: success
< X-Exit-Description: Delivered email to specified email address with certificate signing request attached.
< X-Exit-Output-Friendly-Name: RSS feed XML
< Content-Length: 26
< ETag: W/"1a-NnuclRv86ZEKA9WB967iUGlz84s"
< Set-Cookie: sails.sid=s%3AbpaKOTbNe4E911qH4z1-12ABGd_z2d2I.mAimDARoZgnq8zpJHcF95y8qFJXX0iky4Suj0HUKjpI; Path=/; HttpOnly
< Date: Wed, 22 May 2024 18:22:07 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5
<
* Connection #0 to host localhost left intact
{"csr":"UEQ5NGJXdy4uLg=="}
```

# Checklist for submitter

- [x] Manual QA for all new/changed functionality

---------

Co-authored-by: Eric <eashaw@sailsjs.com>
2024-05-28 10:08:03 -03:00
..
controllers allow to customize the signed CSR return type (#19213) 2024-05-28 10:08:03 -03:00
helpers Schema: change default block scalar used in schema override files (#19296) 2024-05-27 18:18:56 -05:00
hooks/custom Website: Update homepage personalization, add note to custom hook. (#18433) 2024-04-19 17:40:45 -05:00
models Website: add psychologicalStage to User model (#18408) 2024-04-18 21:18:36 -05:00
policies Website: Add admin tool for generating Fleet Premium licenses. (#8478) 2022-12-05 14:53:16 -06:00
responses Website: Fleet Sandbox (#6380) 2022-08-12 17:31:01 -05:00