Restricting access

Three attributes decide who may see a deployment and who may open its source. edge:user restricts viewing, io:user restricts opening the source in RTCode.io, and io:guest keeps the source of an edge worker public. Visitors sign in with GitHub, Google, Microsoft or Apple, and the owner and the editors of a route are always permitted.

Note: The attributes are read when you deploy and enforced by RTEdge.net. The playground does not enforce them.

Choose what to protect

You want toUse
Let only named people view the deploymentedge:user with their emails or domains.
Let any signed-in user view the deploymentedge:user=*
Let only the owner and the editors view the deploymentedge:user=""
Limit who may open the source with ?io:user with their emails or domains.
Keep the source of an edge worker publicio:guest on the worker.

Restrict viewing with edge:user

Put edge:user on any element, usually a <meta>. List the accounts that may view the deployment, as emails, domains or *. The attribute guards the root page, the exported o:= files and the requests that fall back to the worker.

Allow a team and one outside reviewer

html
<meta edge:user="example.com alice@example.org">
<h1>Roadmap</h1>
<p>Visible to example.com accounts and Alice.</p>

Signed-in @example.com accounts and alice@example.org can view the page, and so can the owner and the editors. An anonymous visitor gets a 401 page with a sign-in link. A signed-in visitor who does not match gets a 403 page.

See edge:user.

Restrict the source with io:user

Anyone can open the source of a deployment with ? unless the deployment has source rules. Add io:user to list who may open it.

Open the source to one company

html
<meta io:user=example.com>
<h1>Public page, private source</h1>

Everyone can view the page. Only the owner, the editors and @example.com accounts can open its source.

The source is private as soon as the deployment has one of these:

See io:user.

Use both gates

The view gate and the source gate are independent, so you can combine them.

Restrict viewing and source to a team

html
<meta edge:user="example.com alice@example.org">
<meta io:user=example.com>
<h1>Team page</h1>

Signed-in @example.com accounts and alice@example.org can view the page. Only @example.com accounts, the owner and the editors can open the source, so Alice can view the page but not open ?.

See how the two gates combine.

Keep a worker demo's source public

Deploying an edge worker makes your source private by default, to the owner and the editors. Add io:guest to every edge worker whose source you want to share.

A worker with a public source

html
<iframe src=:></iframe>
<script type=worker edge io:guest>
  export default { fetch: r => new Response(r.url) }
</script>

With no edge:user and no io:user, anyone can open this deployment's source. A separate <meta io:user>, or any edge:user, would keep the source private even though the worker carries io:guest.

See io:guest.

Write permits

edge:user and io:user take a space-separated list of permits. The Editors field takes the same forms.

person@domain.tld

That exact account.

domain.tld

Any account whose email domain is exactly that domain. example.com matches a@example.com, but not a@mail.example.com.

*

Any signed-in user. It never matches an anonymous visitor, who is asked to sign in instead.

An empty value

An empty or whitespace-only value. Only the owner and the editors pass, but the attribute still switches its gate on.

self Experimental

Accepted and dropped at deploy time, so self alone has the same effect as an empty value: only the owner and the editors pass.

Domain matching is exact: example.com does not match a@mail.example.com, so list each subdomain you want. Write permits and editor entries in lower case.

Add editors

Editors can view protected pages, open protected source and redeploy the route. They pass both gates without appearing in the attributes. A viewer or source-access permit alone does not grant editing rights. See Editors for entry syntax and how the owner adds or removes collaborators.

Warning: * in the Editors field lets any signed-in account view, edit and redeploy the route.

Protect worker APIs yourself

edge:user does not guard explicit worker calls with /:. Check request.rt.user in the worker and answer 401 when it is null. See Protect a worker API and /:.

Redaction does not hide the source

edge:redact and edge:remove change only the HTML that RTEdge.net serves. The source opened with ? still contains the redacted or removed content whenever the source is public, and every deploy also saves the complete source as a version. To keep a value private, keep the source private and keep the value inside a private edge worker. See Keeping secrets out of deployments.

Check what visitors see

RequestVisitorResponse
ViewAnonymous401 page "You are not authenticated.", with a "Sign in" link (::si).
ViewSigned in, not permitted403 page "You are not authorized.", with a "Sign in as a different user" link (::sa).
Source, with ?Anonymous303 redirect through sign-in, then back to ?.
Source, with ?Signed in, not permitted403 page "You are not authorized.", with a "Sign in as a different user" link (::sa).

Open the deployment in a private window to test the anonymous case. ::su shows who you are on a host, and ::owner Experimental tells you whether you own the route. A protected page has no social preview for visitors who are not permitted. See Error pages.

What happens at deploy

RTEdge.net reads the attributes when you deploy and compiles them into the deployment's access rules. The attributes are removed from the served HTML, and they stay in the authored source. To change who may view or open a deployment, edit the attributes and deploy again.

See also