Legacy --oauth flags moved to Traffic Policy: preserving allowlist semantics during migration
0 reputation · 15 May 2020, 21:02 UTC
0 reputation · 15 May 2020, 21:02 UTC
I am moving an ngrok tunnel definition from the legacy per-tunnel flags (the --oauth option with an email/domain allowlist) to the newer Traffic Policy configuration, where the same control is expressed as an ordered rule with an OAuth action. The goal is to gate a local app behind provider login (e.g., Google) for integration testing, without embedding OAuth client credentials in the app under test.
Traffic Policy rules are evaluated in order and the first matching terminating action wins. The legacy flags had implicit, fixed semantics, so it is unclear whether a hand-written policy reproduces them exactly — particularly the interaction between the OAuth action, the allowlist enforcement, and any additional rules (such as IP restrictions) that were previously separate flags. Behavior parity also appears to depend on the agent version, and I have not confirmed which agent version introduced full coverage of the legacy OAuth options.
--oauth plus an email allowlist into a Traffic Policy rule, what ordering guarantees that unauthenticated requests never reach the upstream app?35275 reputation · 16 May 2020, 06:26 UTC
Place the OAuth action as the first terminating rule in your Traffic Policy. Rules are evaluated in order, and the first matching terminating action wins, so anything placed after the OAuth rule only ever sees requests that already passed authentication and the email/domain allowlist. That ordering is what reproduces the legacy --oauth behavior, where unauthenticated traffic never reached the upstream app.
The legacy flags translate conceptually as follows:
--oauth <provider> → an oauth action with the provider field set--oauth-allow-emails → the allowed-emails list on that same action--oauth-allow-domains → the allowed-domains list on that same actionWhere the legacy flags had fixed, implicit semantics, the Traffic Policy makes the order explicit — which is both the power and the risk. If you previously combined OAuth with other flags (e.g., an IP restriction), you must now decide deliberately whether that rule runs before OAuth (blocking disallowed IPs before the login challenge) or after. Putting a terminating rule before the OAuth action changes effective behavior versus the legacy flags.
Version boundary: Traffic Policies require ngrok agent v3. On agents older than 3.0, the policy configuration is unavailable and the legacy flags must be kept (or the agent upgraded). The exact per-flag coverage across early 3.x releases is something I cannot confirm without checking the current migration guide — treat that as the one detail worth verifying against the docs for your specific agent version before cutover.
ngrok version # confirm 3.x before relying on Traffic PolicyThen test the policy directly: an unauthenticated curl -i against the tunnel hostname should return a redirect to the provider login (or a 401/403), and your upstream app should log nothing. A request from a non-allowlisted account, after authenticating, should be denied at the edge as well. If either request reaches the app, the OAuth rule is not first or not terminating.
For your stated goal — gating an integration-test app without embedding OAuth credentials — edge enforcement is sufficient. The app never sees unauthenticated requests, so duplicating the check adds complexity without adding security.
The exception is when the app needs to know who the user is or enforce finer-grained rules than an email/domain list. In that case, don't redo the OAuth handshake; consume the identity headers ngrok injects into authenticated requests (user email, access token) and authorize from those. Treat those headers as trustworthy only because the edge strips spoofed copies — another reason the OAuth rule must come first and terminate.
OAuth action first, terminating; any pre-auth filters (like IP restrictions) consciously placed before it; app-level checks only for identity-aware logic, using ngrok's injected headers rather than a second OAuth flow. Confirm your agent is v3 and validate with one unauthenticated request before declaring the migration done.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.