fleet/website/api/controllers
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
..
account Website: Clear personalization on logout (#18630) 2024-05-01 12:10:27 -05:00
admin Website: Add admin page to manage the Fleet Sandbox waitlist (#13111) 2023-08-04 18:32:00 -05:00
articles Website update page titles and descriptions (#15645) 2023-12-15 08:06:31 +09:00
customers Website: requested changes from website review (#18923) 2024-05-10 16:33:45 -05:00
dashboard Move fleetdm.com into main Fleet repo (#83) 2020-12-02 14:48:03 -06:00
docs Fleet UI: Update page titles (#15983) 2024-01-12 09:27:56 -05:00
entrance Website: Update round robin in salesforce helpers & move lead creation to save-questionnaire-progress. (#19209) 2024-05-27 16:43:40 -05:00
handbook Fleet UI: Update page titles (#15983) 2024-01-12 09:27:56 -05:00
legal Move fleetdm.com into main Fleet repo (#83) 2020-12-02 14:48:03 -06:00
reports Website: Add state of device management (#5936) 2022-06-01 10:31:10 -05:00
try-fleet Website: Update /try-fleet (#17608) 2024-03-14 10:28:23 -05:00
webhooks Remove former employee from receive-from-github.js (#19189) 2024-05-24 19:29:00 -05:00
create-or-update-one-newsletter-subscription.js Website: Add Newsletter banner and NewsletterSubscription model (#7370) 2022-09-02 17:38:34 -05:00
create-vanta-authorization-request.js Website: Update error handling in create-vanta-authorization-request (#18462) 2024-04-22 16:58:08 -05:00
deliver-apple-csr.js allow to customize the signed CSR return type (#19213) 2024-05-28 10:08:03 -03:00
deliver-contact-form-message.js Website: Update round robin in salesforce helpers & move lead creation to save-questionnaire-progress. (#19209) 2024-05-27 16:43:40 -05:00
deliver-demo-signup.js Add Q&A signup form to Fleet homepage (#4224) 2022-02-16 11:15:55 +09:00
deliver-mdm-beta-signup.js Website: sails.helpers.iq.getEnriched() and use code instead of nocode (#18538) 2024-04-26 01:50:31 -05:00
deliver-mdm-demo-email.js Website: Add MDM demo video modal to /device-management (#12380) 2023-06-16 15:08:24 -05:00
deliver-talk-to-us-form-submission.js Website: Update round robin in salesforce helpers & move lead creation to save-questionnaire-progress. (#19209) 2024-05-27 16:43:40 -05:00
download-rss-feed.js Fleet UI: Update page titles (#15983) 2024-01-12 09:27:56 -05:00
download-sitemap.js Website: Add missing pages to sitemap (#18762) 2024-05-06 07:16:36 -05:00
get-human-interpretation-from-osquery-sql.js Tiny tweak to a comment (#18709) 2024-05-02 17:39:39 -05:00
save-questionnaire-progress.js Website: Update round robin in salesforce helpers & move lead creation to save-questionnaire-progress. (#19209) 2024-05-27 16:43:40 -05:00
unsubscribe-from-all-newsletters.js Website: Add Newsletter banner and NewsletterSubscription model (#7370) 2022-09-02 17:38:34 -05:00
view-connect-vanta.js Website: Add Vanta integration (#9072) 2022-12-21 23:39:39 -06:00
view-contact.js Website: update contact page personalization (#18332) 2024-04-16 14:55:53 -05:00
view-device-management.js Website: Update view-device-management.js (#18752) 2024-05-03 17:31:30 -05:00
view-endpoint-ops.js Website: update personalization on homepage and endpoint ops (#18616) 2024-04-29 16:40:57 -05:00
view-faq.js Move fleetdm.com into main Fleet repo (#83) 2020-12-02 14:48:03 -06:00
view-fleetctl-preview.js Website: Add steps to /start questionnaire (#18074) 2024-04-08 19:39:19 +09:00
view-homepage-or-redirect.js Handbook: Make the website feel more like home (#17317) 2024-03-01 17:47:37 -06:00
view-integrations.js Website: Add integrations page (#14128) 2023-10-05 08:52:19 +09:00
view-osquery-table-details.js Website: Add Docsearch to /tables pages (#9517) 2023-01-26 14:48:39 -06:00
view-press-kit.js Add fleetdm.com/press-kit (#1981) 2021-09-10 06:56:29 +09:00
view-pricing.js Website: Update categories on pricing page features table (#15835) 2023-12-22 18:35:16 -06:00
view-query-detail.js Website update page titles and descriptions (#15645) 2023-12-15 08:06:31 +09:00
view-query-library.js Obviate doc-templater dependency + dynamic sitemap.xml (#827) 2021-05-26 03:24:38 -05:00
view-start.js Website: redirect admins to the license key generator (#18417) 2024-04-19 10:10:41 -05:00
view-support.js Website: add /support page (#12457) 2023-06-23 18:06:04 -05:00
view-transparency.js Launch transparency page for fleetdm.com (#1391) 2021-07-15 09:48:21 -05:00
view-vanta-authorization.js Website: Add Vanta integration (#9072) 2022-12-21 23:39:39 -06:00
view-vulnerability-management.js Website: add testimonial (#16689) 2024-02-12 16:40:56 -06:00