-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #705 from openziti/interstitial
Interstitial Pages Implementation (#704)
- Loading branch information
Showing
19 changed files
with
442 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package store | ||
|
||
import ( | ||
"github.com/jmoiron/sqlx" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func (str *Store) IsAccountGrantedSkipInterstitial(acctId int, trx *sqlx.Tx) (bool, error) { | ||
stmt, err := trx.Prepare("select count(0) from skip_interstitial_grants where account_id = $1") | ||
if err != nil { | ||
return false, errors.Wrap(err, "error preparing skip_interstitial_grants select statement") | ||
} | ||
var count int | ||
if err := stmt.QueryRow(acctId).Scan(&count); err != nil { | ||
return false, errors.Wrap(err, "error querying skip_interstitial_grants count") | ||
} | ||
return count > 0, nil | ||
} |
13 changes: 13 additions & 0 deletions
13
controller/store/sql/postgresql/029_v0_4_36_skip_interstitial_grants.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- +migrate Up | ||
|
||
create table skip_interstitial_grants ( | ||
id serial primary key, | ||
|
||
account_id integer references accounts (id) not null, | ||
|
||
created_at timestamptz not null default(current_timestamp), | ||
updated_at timestamptz not null default(current_timestamp), | ||
deleted boolean not null default(false) | ||
); | ||
|
||
create index skip_interstitial_grants_id_idx on skip_interstitial_grants (account_id); |
13 changes: 13 additions & 0 deletions
13
controller/store/sql/sqlite3/029_v0_4_36_skip_interstitial_grants.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- +migrate Up | ||
|
||
create table skip_interstitial_grants ( | ||
id integer primary key, | ||
|
||
account_id integer references accounts (id) not null, | ||
|
||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')), | ||
deleted boolean not null default(false) | ||
); | ||
|
||
create index skip_interstitial_grants_id_idx on skip_interstitial_grants (account_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: Interstitial Pages | ||
sidebar_label: Interstitial Pages | ||
sidebar_position: 18 | ||
--- | ||
|
||
On large zrok installations that support open registration and shared public frontends, abuse can become an issue. In order to mitigate phishing and other similar forms of abuse, zrok offers an interstitial page that announces to the visiting user that the share is hosted through zrok, and probably isn't their financial institution. | ||
|
||
Interstitial pages can be enabled on a per-frontend basis. This allows the interstitial to be enabled on open public frontends but not closed public frontends (closed public frontends require a grant to use). | ||
|
||
The interstitial page requirement can also be overridden on a per-account basis, allowing shares created by specific accounts to bypass the interstitial requirement on frontends that enable it. This facilitates building infrastructure that grants trusted users additional privileges. | ||
|
||
By default, if you do not specifically enable interstitial pages on a public frontend, then your self-hosted service instance will not offer them. | ||
|
||
Let's take a look at how the interstitial pages mechanism works. The following diagram shows the share configuration rendezvous made between the zrok controller and a zrok frontend: | ||
|
||
![zrok_interstitial_rendezvous](../../images/zrok_interstitial_rendezvous.png) | ||
|
||
Every zrok share has a _config_ recorded in the underlying OpenZiti network. The config is of type `zrok.proxy.v1`. The frontend uses the information in this config to understand the disposition of the share. The config can contain an `interstitial: true` setting. If the config has this setting, and the frontend is configured to enable interstitial pages, then end users accessing the share will receive the interstitial page on first visit. | ||
|
||
By default the zrok controller will record `interstitial: true` in the share config _unless_ a row is present in the `skip_interstitial_grants` table in the underlying database for the account creating the share. The `skip_interstitial_grants` table is a basic SQL structure that allows inserting a row per account. | ||
|
||
``` | ||
create table skip_interstitial_grants ( | ||
id serial primary key, | ||
account_id integer references accounts (id) not null, | ||
created_at timestamptz not null default(current_timestamp), | ||
updated_at timestamptz not null default(current_timestamp), | ||
deleted boolean not null default(false) | ||
); | ||
``` | ||
|
||
If an account has a row present in this table when creating a share, then the controller will write `interstitial: false` into the config for the share, which will bypass the interstitial regardless of frontend configuration. The `skip_interstitial_grants` controls what the zrok controller will store in the share config when creating the share. | ||
|
||
The frontend configuration controls what the frontend will do with the share config it finds in OpenZiti. The new stanza looks like this: | ||
|
||
``` | ||
# Setting the `interstitial` setting to `true` will allow this frontend | ||
# to offer interstitial pages if they are configured on the share by the | ||
# controller. | ||
# | ||
#interstitial: true | ||
``` | ||
|
||
Simply setting `interstitial: true` in the frontend config will allow the configured frontend to offer an interstitial page if the share config enables the interstitial page for that share. | ||
|
||
## Bypassing the Interstitial | ||
|
||
The interstitial page will be presented unless the client shows up with a `zrok_interstitial` cookie. When the user is presented with the interstitial page, there is a button they can click which sets the necessary cookie and allows them to visit the site. The cookie is set to expire in one week. | ||
|
||
End users can offer an HTTP header of `skip_zrok_interstitial`, set to any value to bypass the interstitial page. Setting this header means that the user most likely understands what a zrok share is and will hopefully not fall for a phishing attack. | ||
|
||
The `skip_zrok_interstitial` header is especially useful for API clients (like `curl`) and other types of non-interactive clients. | ||
|
||
The `drive` backend mode does not currently support `GET` requests and cannot be accessed with a conventional web browser, so it bypasses the interstitial page requirement. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package interstitialUi | ||
|
||
import "embed" | ||
|
||
//go:embed index.html | ||
var FS embed.FS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package interstitialUi | ||
|
||
import ( | ||
"github.com/sirupsen/logrus" | ||
"net/http" | ||
) | ||
|
||
func WriteInterstitialAnnounce(w http.ResponseWriter) { | ||
if data, err := FS.ReadFile("index.html"); err == nil { | ||
w.WriteHeader(http.StatusOK) | ||
n, err := w.Write(data) | ||
if n != len(data) { | ||
logrus.Errorf("short write") | ||
return | ||
} | ||
if err != nil { | ||
logrus.Error(err) | ||
return | ||
} | ||
} | ||
} |
Oops, something went wrong.