Juri Uschakow
05/11/2021, 8:46 PMJason Bosco
05/11/2021, 8:50 PMJason Bosco
05/11/2021, 8:51 PMSo I would like that my user calls a google cloud function and the cloud function calls typesense. Is it OK like that?This is also ok, but I don't think Google Cloud functions provide DDOS protection at least at the scale that Cloudflare offers. Also Cloudflare DNS is free for this use case 🙂
Juri Uschakow
05/11/2021, 8:55 PMJason Bosco
05/11/2021, 8:55 PMJason Bosco
05/11/2021, 8:55 PMJason Bosco
05/11/2021, 8:56 PMJason Bosco
05/11/2021, 8:57 PMJuri Uschakow
05/11/2021, 8:57 PMJason Bosco
05/11/2021, 9:00 PMJuri Uschakow
05/11/2021, 9:00 PMJuri Uschakow
05/11/2021, 9:02 PMJason Bosco
05/11/2021, 9:03 PME.g I program an app like WhatsApp, can I create automatically millions of scooped API keys for auth, so that users will be able to ONLY search through their own messages?Yup!
(i know it would be expensive af to do that, just askin cuz it's an easy example)It's actually not expensive to create scoped API keys. They're not actually created on the Typesense server-side. You can just generate one parent API key on the server-side and with that one key, you can create any number of scoped keys by cryptographically embedding filters inside the key, without touching the server. More details here (under scoped api key): https://typesense.org/docs/0.20.0/api/api-keys.html#generate-scoped-search-key
Jason Bosco
05/11/2021, 9:05 PMSo attackers won't be able to find out the xxx-1.a1.typesense.net URL to ddos it? So I basically need to setup the URL like a uuid4 qpdjcjjdkeoe28384848ejrjdj-1.a1.typesense.netCloudflare doesn't reveal the hostname(s) that it proxies to. So all your users will see is that requests are being made to typesense1.yourdomain.com That hostname points to a set of Cloudflare edge IPs. Behind the scenes, cloudflare will then proxy the call to the Typesense Cloud hostname. So your end users won't see the Typesense Cloud hostname anywhere for them to reach it
Jason Bosco
05/11/2021, 9:11 PMJason Bosco
05/11/2021, 9:12 PM$ dig <http://tungsten.example.com|tungsten.example.com>
; <<>> DiG 9.10.6 <<>> <http://tungsten.example.com|tungsten.example.com>
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45761
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;tungsten.example.com. IN A
;; ANSWER SECTION:
<http://tungsten.example.com|tungsten.example.com>. 300 IN A 104.26.10.144
<http://tungsten.example.com|tungsten.example.com>. 300 IN A 172.67.68.165
<http://tungsten.example.com|tungsten.example.com>. 300 IN A 104.26.11.144
;; Query time: 88 msec
;; SERVER: 192.168.7.1#53(192.168.7.1)
;; WHEN: Tue May 11 14:12:11 PDT 2021
;; MSG SIZE rcvd: 97
Those 3 IPs are Cloudflare IPs and not the one I set in the Cloudflare DNS admin.
That's because Cloudflare proxies the request through their network and the end user never sees the actual IP the request is being made to.Juri Uschakow
05/11/2021, 9:13 PMJason Bosco
05/11/2021, 9:17 PMwith thisIsTheKeyIGiveMyClient my Client can search with this key his company data, right?Correct.
keyWithSearchPermissions = 'randomuuidv4keyfortheuser/orhisAUTHkey(google generates every 60 minutes a new one)'The parent search key is something you'd have to generate using the
/keys
endpoint in Typesense. You don't have to necessarily rotate it every 60 minutes, you could if you want to of course. But typically you'd generate it once by hand say on your local machine, and then store that in your secrets vault (or however you distribute secrets to your cloud function) and then use that to generate scoped API keys on the fly for every user.Juri Uschakow
05/11/2021, 9:17 PMJason Bosco
05/11/2021, 9:17 PMJuri Uschakow
05/11/2021, 9:19 PMJason Bosco
05/11/2021, 9:19 PMJuri Uschakow
05/11/2021, 9:24 PMJason Bosco
05/11/2021, 9:26 PMJuri Uschakow
05/11/2021, 9:42 PMJason Bosco
05/11/2021, 9:58 PMRicardo
05/12/2021, 4:34 AM