#community-help

Clarifying Key Creation Permissions in Coding

TLDR Ricardo asked if a non-bootstrap key can generate keys. Jason affirmed and clarified the role of "actions * " and "collections * ". Ricardo suggested adding this info to the documentation.

Powered by Struct AI
9
30mo
Solved
Join the chat
Jun 01, 2021 (30 months ago)
Ricardo
Photo of md5-a2785b9d22ba23f3627d4bd877e95e7c
Ricardo
05:45 PM
key = client.keys.create({
  "description": "Admin key.",
  "actions": ["*"],
  "collections": ["*"]
})

This can't create keys right?
is the bootstrap key the only key that can create keys?
one key to rule them all?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:49 PM
That's correct, you'd need to use the bootstrap api key to initialize the client and generate your first admin key
Jun 02, 2021 (30 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:14 AM
To clarify, once you have your first admin key generated from the bootstrap api key, you can then create additional admin keys with that generated admin api key
Ricardo
Photo of md5-a2785b9d22ba23f3627d4bd877e95e7c
Ricardo
05:37 AM
I'm a bit confused then. can the key created in my example above create other keys?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:45 AM
Yes it can. I initially misunderstood your original question.
Ricardo
Photo of md5-a2785b9d22ba23f3627d4bd877e95e7c
Ricardo
07:33 AM
I see, so what defines a key as being able to create keys.
Is it an action or a collection? I'm guessing the action * ?
key = client.keys.create({
  "description": "Almost Admin key.",
  "actions": ["collections:*"],
  "collections": ["*"]
})

So from my understanding this key can do every action on collections, but not create new keys?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:52 PM
It's actions * and collections * that makes it an admin key.

The key generated with the snippet above shouldn't allow you to create new keys...
Jun 03, 2021 (30 months ago)
Ricardo
Photo of md5-a2785b9d22ba23f3627d4bd877e95e7c
Ricardo
01:55 AM
Jason cool can I put in a pull request to add this to the docs?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
01:56 AM
Yes please, thank you!