mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
cleanups for OAuth in sdk.ShareRequest (#404)
This commit is contained in:
parent
957e50412e
commit
27fcf98fbd
@ -83,7 +83,7 @@ func (cmd *reserveCommand) run(_ *cobra.Command, args []string) {
|
||||
req := &sdk.ShareRequest{
|
||||
BackendMode: sdk.BackendMode(cmd.backendMode),
|
||||
ShareMode: shareMode,
|
||||
Auth: cmd.basicAuth,
|
||||
BasicAuth: cmd.basicAuth,
|
||||
Target: target,
|
||||
}
|
||||
if shareMode == sdk.PublicShareMode {
|
||||
|
@ -99,7 +99,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
||||
req := &sdk.ShareRequest{
|
||||
BackendMode: sdk.BackendMode(cmd.backendMode),
|
||||
ShareMode: sdk.PrivateShareMode,
|
||||
Auth: cmd.basicAuth,
|
||||
BasicAuth: cmd.basicAuth,
|
||||
Target: target,
|
||||
}
|
||||
shr, err := sdk.CreateShare(root, req)
|
||||
|
@ -105,10 +105,9 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
||||
BackendMode: sdk.BackendMode(cmd.backendMode),
|
||||
ShareMode: sdk.PublicShareMode,
|
||||
Frontends: cmd.frontendSelection,
|
||||
Auth: cmd.basicAuth,
|
||||
BasicAuth: cmd.basicAuth,
|
||||
Target: target,
|
||||
}
|
||||
|
||||
if cmd.oauthProvider != "" {
|
||||
req.OauthProvider = cmd.oauthProvider
|
||||
req.OauthEmailDomains = cmd.oauthEmailDomains
|
||||
|
@ -22,9 +22,9 @@ const (
|
||||
type ShareRequest struct {
|
||||
BackendMode BackendMode
|
||||
ShareMode ShareMode
|
||||
Frontends []string
|
||||
Auth []string
|
||||
Target string
|
||||
Frontends []string
|
||||
BasicAuth []string
|
||||
OauthProvider string
|
||||
OauthEmailDomains []string
|
||||
OauthAuthorizationCheckInterval time.Duration
|
||||
|
@ -26,14 +26,14 @@ func CreateShare(root env_core.Root, request *ShareRequest) (*Share, error) {
|
||||
return nil, errors.Errorf("unknown share mode '%v'", request.ShareMode)
|
||||
}
|
||||
|
||||
if len(request.Auth) > 0 {
|
||||
if len(request.BasicAuth) > 0 {
|
||||
out.Body.AuthScheme = string(Basic)
|
||||
for _, pair := range request.Auth {
|
||||
tokens := strings.Split(pair, ":")
|
||||
for _, basicAuthUser := range request.BasicAuth {
|
||||
tokens := strings.Split(basicAuthUser, ":")
|
||||
if len(tokens) == 2 {
|
||||
out.Body.AuthUsers = append(out.Body.AuthUsers, &rest_model_zrok.AuthUser{Username: strings.TrimSpace(tokens[0]), Password: strings.TrimSpace(tokens[1])})
|
||||
} else {
|
||||
return nil, errors.Errorf("invalid username:password pair '%v'", pair)
|
||||
return nil, errors.Errorf("invalid username:password '%v'", basicAuthUser)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user