Hello. How would I scope an api key to allow searc...
# community-help
j
Hello. How would I scope an api key to allow searches on all collections AND permissions to list the collections, aliases and get metrics? I have this for search
"actions": ["documents:search"], "collections": ["*"]
, which works, but the others permissions I'm unsure about.
j
Could you try aliases:get and metrics:get?
j
I tried that and I still get a "Forbidden" for the key:
Copy code
^_^[james@ganymede:~]$ export TS_ADM_KEY=<REDACTED>
^_^[james@ganymede:~]$ curl '<http://localhost:8108/keys>' \
> -X POST \
> -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}" \
> -H 'Content-Type: application/json' \
> -d '{"description": "Minimal UI key", "actions": ["documents:search","metrics:get","aliases:get"], "collections": ["*"]}'
{"actions":["documents:search","metrics:get","aliases:get"],"collections":["*"],"description":"Minimal UI key","expires_at":64723363199,"id":4,"value":"<MIN_API_KEY>"}

^_^[james@ganymede:~]$
^_^[james@ganymede:~]$
^_^[james@ganymede:~]$ export MIN_API_KEY=<MIN_API_KEY>
^_^[james@ganymede:~]$ curl '<http://localhost:8108/aliases>' \
> -H "X-TYPESENSE-API-KEY: ${MIN_API_KEY}"
{"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."}^_^[james@ganymede:~]$
^_^[james@ganymede:~]$
^_^[james@ganymede:~]$ curl '<http://elastic-master:8108/metrics.json>' -H "X-TYPESENSE-API-KEY: ${MIN_API_KEY}"
{"message": "Forbidden - a valid `x-typesense-api-key` header must be sent."}
^_^[james@ganymede:~]$
does work with admin key (as you would expect):
Copy code
^_^[james@ganymede:~]$ curl '<http://localhost:8108/aliases>' -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}"
{"aliases":[{"collection_name":"scimago-20210913","name":"scimago"},{"collection_name":"search-20210913","name":"search"},{"collection_name":"openurl-20210914","name":"openurl"},{"collection_name":"browse-20210913","name":"browse"},{"collection_name":"content-20210913","name":"content"}]}
^_^[james@ganymede:~]$ curl '<http://localhost:8108/metrics.json>' -H "X-TYPESENSE-API-KEY: ${TS_ADM_KEY}"
{
  "system_cpu1_active_percentage": "0.00",
  "system_cpu_active_percentage": "0.00",
  "system_disk_total_bytes": "25832407040",
  "system_disk_used_bytes": "4128784384",
  "system_memory_total_bytes": "1028968448",
  "system_memory_used_bytes": "479678464",
  "system_network_received_bytes": "1465995489",
  "system_network_sent_bytes": "256701323",
  "typesense_memory_active_bytes": "178778112",
  "typesense_memory_allocated_bytes": "173139992",
  "typesense_memory_fragmentation_ratio": "0.03",
  "typesense_memory_mapped_bytes": "193572864",
  "typesense_memory_metadata_bytes": "8894784",
  "typesense_memory_resident_bytes": "178778112",
  "typesense_memory_retained_bytes": "198070272"
}
^_^[james@ganymede:~]$
j
@Kishore Nallan ^