mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
raise an exception if invalid mode for public share
This commit is contained in:
parent
795b953845
commit
799900d477
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"time"
|
"time"
|
||||||
|
"slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -34,7 +35,7 @@ func newReserveCommand() *reserveCommand {
|
|||||||
}
|
}
|
||||||
command := &reserveCommand{cmd: cmd}
|
command := &reserveCommand{cmd: cmd}
|
||||||
cmd.Flags().StringArrayVar(&command.frontendSelection, "frontends", []string{"public"}, "Selected frontends to use for the share")
|
cmd.Flags().StringArrayVar(&command.frontendSelection, "frontends", []string{"public"}, "Selected frontends to use for the share")
|
||||||
cmd.Flags().StringVarP(&command.backendMode, "backend-mode", "b", "proxy", "The backend mode {proxy, web, <tcpTunnel, udpTunnel>, caddy, drive}")
|
cmd.Flags().StringVarP(&command.backendMode, "backend-mode", "b", "proxy", "The backend mode (public|private: proxy, web, caddy, drive) (private: tcpTunnel, udpTunnel)")
|
||||||
cmd.Flags().BoolVarP(&command.jsonOutput, "json-output", "j", false, "Emit JSON describing the created reserved share")
|
cmd.Flags().BoolVarP(&command.jsonOutput, "json-output", "j", false, "Emit JSON describing the created reserved share")
|
||||||
cmd.Flags().StringArrayVar(&command.basicAuth, "basic-auth", []string{}, "Basic authentication users (<username:password>,...)")
|
cmd.Flags().StringArrayVar(&command.basicAuth, "basic-auth", []string{}, "Basic authentication users (<username:password>,...)")
|
||||||
cmd.Flags().StringVar(&command.oauthProvider, "oauth-provider", "", "Enable OAuth provider [google, github]")
|
cmd.Flags().StringVar(&command.oauthProvider, "oauth-provider", "", "Enable OAuth provider [google, github]")
|
||||||
@ -48,8 +49,11 @@ func newReserveCommand() *reserveCommand {
|
|||||||
|
|
||||||
func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
||||||
shareMode := sdk.ShareMode(args[0])
|
shareMode := sdk.ShareMode(args[0])
|
||||||
|
privateOnlyModes := []string{"tcpTunnel", "udpTunnel"}
|
||||||
if shareMode != sdk.PublicShareMode && shareMode != sdk.PrivateShareMode {
|
if shareMode != sdk.PublicShareMode && shareMode != sdk.PrivateShareMode {
|
||||||
tui.Error("invalid sharing mode; expecting 'public' or 'private'", nil)
|
tui.Error("invalid sharing mode; expecting 'public' or 'private'", nil)
|
||||||
|
} else if shareMode == sdk.PublicShareMode && slices.Contains(privateOnlyModes, cmd.backendMode) {
|
||||||
|
tui.Error(fmt.Sprintf("invalid sharing mode for a %s share: %s", sdk.PublicShareMode, cmd.backendMode), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
var target string
|
var target string
|
||||||
|
@ -82,7 +82,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
target = args[0]
|
target = args[0]
|
||||||
|
|
||||||
default:
|
default:
|
||||||
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web}", cmd.backendMode), nil)
|
tui.Error(fmt.Sprintf("invalid backend mode '%v'; expected {proxy, web, caddy, drive}", cmd.backendMode), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
root, err := environment.LoadRoot()
|
root, err := environment.LoadRoot()
|
||||||
|
@ -293,7 +293,7 @@ Usage:
|
|||||||
zrok share public <target> [flags]
|
zrok share public <target> [flags]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
--backend-mode string The backend mode {proxy, web} (default "proxy")
|
--backend-mode string The backend mode {proxy, web, caddy, drive} (default "proxy")
|
||||||
--basic-auth stringArray Basic authentication users (<username:password>,...)
|
--basic-auth stringArray Basic authentication users (<username:password>,...)
|
||||||
--frontends stringArray Selected frontends to use for the share (default [public])
|
--frontends stringArray Selected frontends to use for the share (default [public])
|
||||||
--headless Disable TUI and run headless
|
--headless Disable TUI and run headless
|
||||||
|
@ -120,14 +120,14 @@ Both the `google` and `github` providers accept a `client_id` and `client_secret
|
|||||||
|
|
||||||
With your public frontend configured to support OAuth, you can test this by creating a public share. There are new command line options to support this:
|
With your public frontend configured to support OAuth, you can test this by creating a public share. There are new command line options to support this:
|
||||||
|
|
||||||
```
|
```text
|
||||||
$ zrok share public
|
$ zrok share public
|
||||||
Error: accepts 1 arg(s), received 0
|
Error: accepts 1 arg(s), received 0
|
||||||
Usage:
|
Usage:
|
||||||
zrok share public <target> [flags]
|
zrok share public <target> [flags]
|
||||||
|
|
||||||
Flags:
|
Flags:
|
||||||
-b, --backend-mode string The backend mode {proxy, web, caddy} (default "proxy")
|
-b, --backend-mode string The backend mode {proxy, web, caddy, drive} (default "proxy")
|
||||||
--basic-auth stringArray Basic authentication users (<username:password>,...)
|
--basic-auth stringArray Basic authentication users (<username:password>,...)
|
||||||
--frontends stringArray Selected frontends to use for the share (default [public])
|
--frontends stringArray Selected frontends to use for the share (default [public])
|
||||||
--headless Disable TUI and run headless
|
--headless Disable TUI and run headless
|
||||||
@ -150,7 +150,6 @@ The `--oauth-check-interval` flag specifies how frequently the authentication mu
|
|||||||
|
|
||||||
An example public share:
|
An example public share:
|
||||||
|
|
||||||
|
```text
|
||||||
|
zrok share public --backend-mode web --oauth-provider github --oauth-email-domains zrok.io ~/public
|
||||||
```
|
```
|
||||||
$ zrok share public --backend-mode web --oauth-provider github --oauth-email-domains zrok.io ~/public
|
|
||||||
```
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user