buildkite / docs

The source files for the Buildkite documentation
https://buildkite.com/docs
MIT License
46 stars 249 forks source link

Clarity on Agent Access Token Scope #1413

Open abhishekmukherg opened 2 years ago

abhishekmukherg commented 2 years ago

Hey! I was hoping to get some clarity on Scope of Access. In the doc, it describes that an agent access token can be used to register an agent to a queue. What else can it (or the session token) do? Can it

Thanks!

abhishekmukherg commented 2 years ago

One more I have interest in is if an agent token can enable a process to write to the stdout of a job -- for example, it's not clear to me if log streaming is effectively locked to an existing TCP socket, and if there's any reconnection logic

plaindocs commented 2 years ago

Hi @abhishekmukherg I took a look at this, and dug a bit further.

Does this answer you question?

I'll update and consolidate the docs so that this is all easier to find in the meantime.

abhishekmukherg commented 2 years ago

Hi! I think that answers the majority of my questions. Just a couple clarifying ones though that I think the docs could benefit from clarity on:

Thanks!

moskyb commented 2 years ago

hi there @abhishekmukherg! i can answer some of your questions.

could one trade the Registration Token for a Session Token?

yep. the way the agent does this is that it calls the https://agent.buildkite.com/v3/register endpoint with its registration token in the authorization header, and that API response is an agent access token that has permission to do agenty things. The agent then ingests the agent access token from this response, and uses it to do agenty things from then on.

Does a session token grant read/write access for the things it can do to all jobs/pipelines?

i believe so, yes. agents can be long-running, so they might get launched to service one pipeline, but might pick up work for another after the first one is done, so they need access to all pipelines/jobs. feel free to correct me if i'm wrong here though @plaindocs! i'm pretty new 😅

can an agent token enable a process to write to the stdout of a job?

also yes. job log streaming happens on the https://agent.buildkite.com/v3/jobs/chunks agent api endpoint, which is authenticated using the agent access token. the result of this is that if a bad actor had access to your agent access token, they could write bad logs, but they can't remove any logs. The endpoint is append-only.