wiring up the private share cli to the permission mode; sqlite tweak (#432)

This commit is contained in:
Michael Quigley 2024-03-05 12:44:56 -05:00
parent 6ba4460eb7
commit 1882783892
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 14 additions and 6 deletions

View File

@ -25,11 +25,13 @@ func init() {
}
type sharePrivateCommand struct {
basicAuth []string
backendMode string
headless bool
insecure bool
cmd *cobra.Command
basicAuth []string
backendMode string
headless bool
insecure bool
closed bool
accessGrants []string
cmd *cobra.Command
}
func newSharePrivateCommand() *sharePrivateCommand {
@ -43,6 +45,8 @@ func newSharePrivateCommand() *sharePrivateCommand {
cmd.Flags().StringVarP(&command.backendMode, "backend-mode", "b", "proxy", "The backend mode {proxy, web, tcpTunnel, udpTunnel, caddy, drive, socks}")
cmd.Flags().BoolVar(&command.headless, "headless", false, "Disable TUI and run headless")
cmd.Flags().BoolVar(&command.insecure, "insecure", false, "Enable insecure TLS certificate validation for <target>")
cmd.Flags().BoolVar(&command.closed, "closed", false, "Enable closed permission mode (see --access-grant)")
cmd.Flags().StringArrayVar(&command.accessGrants, "access-grant", []string{}, "zrok accounts that area allowed to access this share (see --closed)")
cmd.Run = command.run
return command
}
@ -131,6 +135,10 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
BasicAuth: cmd.basicAuth,
Target: target,
}
if cmd.closed {
req.PermissionMode = sdk.ClosedPermissionMode
req.AccessGrants = cmd.accessGrants
}
shr, err := sdk.CreateShare(root, req)
if err != nil {
if !panicInstead {

View File

@ -3,7 +3,7 @@
alter table shares add column permission_mode string not null default('open');
create table access_grants (
id serial primary key,
id integer primary key,
share_id integer references shares(id),
account_id integer references accounts(id),
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),