# Restrict auth tokens to certain actions (create-deploy)

**URL:** <https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098>\
**Category:** Features\
**Tags:** authentication, deployment\
**Created:** [October 9, 2020, 9:58am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098 "2020-10-09T09:58:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![eps1lon](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/eps1lon/32/7711_2.png) [@eps1lon](https://answers.netlify.com/u/eps1lon)\
**Post date:** [October 9, 2020, 9:58am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/1 "2020-10-09T09:58:34Z")

</div>

As far as I can tell personal access tokens allow any actions. We’d like to limit the allowed actions to only create a deploy in case a key leaks and a malicious actor e.g. deletes a site.

**Context**

We’d like to move from netlify’s CD platform to azure since Azure is twice as fast and has way more free minutes.  
It seems like we can already do that with the netlify cli (build+deploy) but we need an access token. Since we’d also like to build pull requests from forks we would need to make that token available to these PRs. While there are certain measures in place to prevent leaking it’s never 100% safe. We’d be fine with potential leakage if that only results in deploys being created. But e.g. removing sites is to great of a risk.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [October 12, 2020, 6:30pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/2 "2020-10-12T18:30:16Z")

</div>

Great suggestion, @eps1lon! We don’t have it implemented yet, but I have added your voice to our existing feature request.

However, you don’t have to do this in the way you describe; we already have good support for building PR’s against your repo though, without your contributors doing anything, as long as you (not they) configure builds from git.

- Start by allowing builds for any branch(es) that people would PR against in your build & deploy settings page
- then enable “safer” PR’s based on the sensitivity of your environment variables, as described here: [Build environment variables | Netlify Docs](https://docs.netlify.com/configure-builds/environment-variables/#sensitive-variable-policy)

But yes, “limited scope” access tokens to allow CLI usage are not available today. We’ll follow up in this thread if we make them available! Not clear that we will, but we’ll see what time brings 🙂

---

<div class="post-metadata">

**Author:** ![eps1lon](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/eps1lon/32/7711_2.png) [@eps1lon](https://answers.netlify.com/u/eps1lon)\
**Post date:** [October 16, 2020, 12:32am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/4 "2020-10-16T00:32:43Z")

</div>

> However, you don’t have to do this in the way you describe; we already have good support for building PR’s against your repo though

This is not our observation. Building on netlify is slow due to limited resources and requires extra payment from our side. Azure has stronger and cheaper resources which is why we want to offload building onto azure.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [October 16, 2020, 7:25pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/5 "2020-10-16T19:25:48Z")

</div>

Thanks for that feedback!

---

<div class="post-metadata">

**Author:** ![user1](https://avatars.discourse-cdn.com/v4/letter/u/5daacb/32.png) [@user1](https://answers.netlify.com/u/user1)\
**Post date:** [November 19, 2020, 8:27pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/6 "2020-11-19T20:27:57Z")

</div>

Just wanted to add on that we’d love to have this feature.

We’re trying to move our build over to GitHub Actions, and we’d like to be able to run deploy previews on PRs from forks without exposing a token that could give a third-party access to our production deploys.

I recognize that this runs counter to Netlify’s business model. We’re a non-profit organization that’s strapped for cash, and 300 build minutes just isn’t enough to cover our needs. It’s unfortunate that we can’t currently outsource our deploy preview builds without risking access to our production deploys, since GitHub Actions offers unlimited build minutes for open-source repos.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [November 29, 2020, 11:15pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/7 "2020-11-29T23:15:14Z")

</div>

Do you have an open source project? We don’t sponsor nonprofits in general, but if it is open source, we’ll sponsor a pro account for you, which includes free collaborators, and more build minutes:

> **[Open Source Plan Policy](https://www.netlify.com/legal/open-source-policy/)**
>
> A powerful serverless platform with an intuitive git-based workflow. Automated deployments, shareable previews, and much more. Get started for free!

---

<div class="post-metadata">

**Author:** ![user1](https://avatars.discourse-cdn.com/v4/letter/u/5daacb/32.png) [@user1](https://answers.netlify.com/u/user1)\
**Post date:** [December 2, 2020, 4:04am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/8 "2020-12-02T04:04:56Z")

</div>

Yes, we have an open source project.

What does “all internal pages” mean (from the Open Source Plan Policy you linked)? We’d be happy to link to Netlify, but we’re not willing to put it on our main page–given the nature of our specific homepage, we feel that it would be inappropriate to put such a link there.

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [December 9, 2020, 10:28pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/9 "2020-12-09T22:28:26Z")

</div>

hi @user1, i would suggest that you apply, and we can discuss in greater detail when we know a bit more about your project?

---

<div class="post-metadata">

**Author:** ![oliviertassinari](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/oliviertassinari/32/2624_2.png) [@oliviertassinari](https://answers.netlify.com/u/oliviertassinari)\
**Post date:** [February 14, 2021, 11:54am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/11 "2021-02-14T11:54:52Z")

</div>

I second this. Not building inside Netlify is also interesting to remove duplicated work the overall CI. For instance, a team might already build its website inside another CI service in order to keep track of performance metrics on the build, e.g. the bundle size of the generated files.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [February 16, 2021, 7:27pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/12 "2021-02-16T19:27:01Z")

</div>

Thanks for the suggestion! We’ve added your voice to the open feature request and we will follow up in this thread should we start providing such tokens.

---

<div class="post-metadata">

**Author:** ![User2](https://avatars.discourse-cdn.com/v4/letter/u/ecb155/32.png) [@User2](https://answers.netlify.com/u/User2)\
**Post date:** [June 26, 2021, 7:53am UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/13 "2021-06-26T07:53:07Z")

</div>

This request seems also to be relevant to security considerations when creating Netlify widgets for Sanity, so I assume that it applies to a lot of similar use cases as well.

You can follow the relevant thread on Github regarding this here:  
[https://github.com/sanity-io/sanity-plugin-dashboard-widget-netlify/issues/14](https://github.com/sanity-io/sanity-plugin-dashboard-widget-netlify/issues/14)

I would be thankful if you could chime in and point us in a direction, if there are any ways around this security issue, that we have missed so far.

Have a wonderful day! ☀

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [July 5, 2021, 3:39pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/14 "2021-07-05T15:39:26Z")

</div>

Hi @User2,

Unfortunately there’s no news on this yet.

---

<div class="post-metadata">

**Author:** ![User2](https://avatars.discourse-cdn.com/v4/letter/u/ecb155/32.png) [@User2](https://answers.netlify.com/u/User2)\
**Post date:** [July 5, 2021, 8:56pm UTC](https://answers.netlify.com/t/restrict-auth-tokens-to-certain-actions-create-deploy/24098/15 "2021-07-05T20:56:39Z")

</div>

Thank you for the info @hrishikesh! 🙂
