-
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 #665 from openziti/frontend_permissions
Frontend Permissions (#539)
- Loading branch information
Showing
18 changed files
with
217 additions
and
23 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
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) IsFrontendGrantedToAccount(acctId, frontendId int, trx *sqlx.Tx) (bool, error) { | ||
stmt, err := trx.Prepare("select count(0) from frontend_grants where account_id = $1 AND frontend_id = $2") | ||
if err != nil { | ||
return false, errors.Wrap(err, "error preparing frontend_grants select statement") | ||
} | ||
var count int | ||
if err := stmt.QueryRow(acctId, frontendId).Scan(&count); err != nil { | ||
return false, errors.Wrap(err, "error querying frontend_grants count") | ||
} | ||
return count > 0, nil | ||
} |
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
17 changes: 17 additions & 0 deletions
17
controller/store/sql/postgresql/027_v0_4_32_frontend_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,17 @@ | ||
-- +migrate Up | ||
|
||
alter table frontends add column permission_mode permission_mode_type not null default('open'); | ||
|
||
create table frontend_grants ( | ||
id serial primary key, | ||
|
||
account_id integer references accounts (id) not null, | ||
frontend_id integer references frontends (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 frontend_grants_account_id_idx on frontend_grants (account_id); | ||
create index frontend_grants_frontend_id_idx on frontend_grants (frontend_id); |
17 changes: 17 additions & 0 deletions
17
controller/store/sql/sqlite3/027_v0_4_32_frontend_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,17 @@ | ||
-- +migrate Up | ||
|
||
alter table frontends add column permission_mode string not null default('open'); | ||
|
||
create table frontend_grants ( | ||
id integer primary key, | ||
|
||
account_id integer references accounts (id) not null, | ||
frontend_id integer references frontends (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 frontend_grants_account_id_idx on frontend_grants (account_id); | ||
create index frontend_grants_frontend_id_idx on frontend_grants (frontend_id); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1 +1 @@ | ||
7.4.0 | ||
7.6.0 |
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
Oops, something went wrong.