Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement API and backend for DynamicWindowsDesktop #46987

Merged
merged 50 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e98d320
Add DynamicWindowsDesktop to proto
probakowski Sep 26, 2024
f61f87c
Add resource matchers to Windows desktop service config
probakowski Sep 26, 2024
9705056
Implement API and backend for DynamicWindowsDesktop
probakowski Sep 27, 2024
129bfff
Fix imports
probakowski Sep 30, 2024
263baee
Merge remote-tracking branch 'origin/master' into probakowski/registe…
probakowski Oct 2, 2024
5767426
move rpc to separate server
probakowski Oct 2, 2024
476f221
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 2, 2024
f99db8b
rework api and grpc more towards 153-style
probakowski Oct 7, 2024
f518ab7
Merge remote-tracking branch 'origin/master' into probakowski/registe…
probakowski Oct 7, 2024
3aca083
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 7, 2024
b4da04f
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 7, 2024
d54b692
e
probakowski Oct 7, 2024
34c79ce
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 7, 2024
d547d83
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 7, 2024
1b568fd
remove dynamic windows from paginated resource
probakowski Oct 7, 2024
752a822
Merge branch 'probakowski/register-resources-config' into probakowski…
probakowski Oct 7, 2024
4013534
add tests
probakowski Oct 8, 2024
c483888
add tests
probakowski Oct 8, 2024
2eba6c7
Merge remote-tracking branch 'origin/master' into probakowski/registe…
probakowski Oct 9, 2024
bed7d62
Update api/proto/teleport/legacy/types/types.proto
probakowski Oct 10, 2024
b3f7598
Merge remote-tracking branch 'origin/master' into probakowski/registe…
probakowski Oct 10, 2024
99f6282
lint
probakowski Oct 10, 2024
8fabe56
Merge remote-tracking branch 'origin/master' into probakowski/registe…
probakowski Oct 14, 2024
247bed9
Merge branch 'probakowski/register-resources-proto' into probakowski/…
probakowski Oct 14, 2024
bf9c121
Merge branch 'master' into probakowski/register-resources-config
probakowski Oct 14, 2024
b3ff70a
gci
probakowski Oct 14, 2024
57310c0
Merge branch 'probakowski/register-resources-config' into probakowski…
probakowski Oct 15, 2024
5dff168
cleanup
probakowski Oct 15, 2024
b57b8d0
cleanup
probakowski Oct 15, 2024
14987eb
use generic service
probakowski Oct 16, 2024
0ccf188
cleanup
probakowski Oct 16, 2024
37c409d
cleanup
probakowski Oct 16, 2024
c8a44c4
cleanup
probakowski Oct 16, 2024
8a4e4a5
Merge branch 'master' into probakowski/register-resources-api
probakowski Oct 16, 2024
b26df6d
cleanup
probakowski Oct 16, 2024
ef90d0d
cleanup
probakowski Oct 16, 2024
e594197
gci
probakowski Oct 16, 2024
97f2b7e
add admin action checks
probakowski Oct 16, 2024
4a51c03
move service
probakowski Oct 16, 2024
5c86920
add service test
probakowski Oct 16, 2024
641dc78
Merge branch 'master' into probakowski/register-resources-api
probakowski Oct 16, 2024
fe18d8b
gci
probakowski Oct 17, 2024
af5dc06
review comments
probakowski Oct 17, 2024
7592f48
review comments
probakowski Oct 17, 2024
88753c6
review comments
probakowski Oct 17, 2024
84af7ce
Merge branch 'master' into probakowski/register-resources-api
probakowski Oct 17, 2024
61db837
review comments
probakowski Oct 21, 2024
e3527b1
review comments
probakowski Oct 21, 2024
8a32003
Merge branch 'master' into probakowski/register-resources-api
probakowski Oct 22, 2024
c990cf5
Merge branch 'master' into probakowski/register-resources-api
probakowski Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import (
"github.com/gravitational/teleport/api/client/accessmonitoringrules"
crownjewelapi "github.com/gravitational/teleport/api/client/crownjewel"
"github.com/gravitational/teleport/api/client/discoveryconfig"
"github.com/gravitational/teleport/api/client/dynamicwindows"
"github.com/gravitational/teleport/api/client/externalauditstorage"
kubewaitingcontainerclient "github.com/gravitational/teleport/api/client/kubewaitingcontainer"
"github.com/gravitational/teleport/api/client/okta"
Expand All @@ -74,6 +75,7 @@ import (
dbobjectimportrulev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/dbobjectimportrule/v1"
devicepb "github.com/gravitational/teleport/api/gen/proto/go/teleport/devicetrust/v1"
discoveryconfigv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/discoveryconfig/v1"
dynamicwindowsv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/dynamicwindows/v1"
externalauditstoragev1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/externalauditstorage/v1"
integrationpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/integration/v1"
kubeproto "github.com/gravitational/teleport/api/gen/proto/go/teleport/kube/v1"
Expand Down Expand Up @@ -2657,6 +2659,10 @@ func (c *Client) SearchSessionEvents(ctx context.Context, fromUTC time.Time, toU
return decodedEvents, response.LastKey, nil
}

func (c *Client) DynamicDesktopClient() *dynamicwindows.Client {
return dynamicwindows.NewClient(dynamicwindowsv1.NewDynamicWindowsServiceClient(c.conn))
}

// ClusterConfigClient returns an unadorned Cluster Configuration client, using the underlying
// Auth gRPC connection.
func (c *Client) ClusterConfigClient() clusterconfigpb.ClusterConfigServiceClient {
Expand Down
93 changes: 93 additions & 0 deletions api/client/dynamicwindows/dynamicwindows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package dynamicwindows

import (
"context"

"github.com/gravitational/trace"

dynamicwindows "github.com/gravitational/teleport/api/gen/proto/go/teleport/dynamicwindows/v1"
"github.com/gravitational/teleport/api/types"
)

// Client is a DynamicWindowsDesktop client.
type Client struct {
grpcClient dynamicwindows.DynamicWindowsServiceClient
}

// NewClient creates a new StaticHostUser client.
func NewClient(grpcClient dynamicwindows.DynamicWindowsServiceClient) *Client {
return &Client{
grpcClient: grpcClient,
}
}

func (c *Client) GetDynamicWindowsDesktop(ctx context.Context, name string) (types.DynamicWindowsDesktop, error) {
desktop, err := c.grpcClient.GetDynamicWindowsDesktop(ctx, &dynamicwindows.GetDynamicWindowsDesktopRequest{
Name: name,
})
return desktop, trace.Wrap(err)
}

func (c *Client) ListDynamicWindowsDesktop(ctx context.Context, pageSize int, pageToken string) ([]types.DynamicWindowsDesktop, string, error) {
resp, err := c.grpcClient.ListDynamicWindowsDesktops(ctx, &dynamicwindows.ListDynamicWindowsDesktopsRequest{
PageSize: int32(pageSize),
probakowski marked this conversation as resolved.
Show resolved Hide resolved
PageToken: pageToken,
})
if err != nil {
return nil, "", trace.Wrap(err)
}
desktops := make([]types.DynamicWindowsDesktop, 0, len(resp.GetDesktops()))
for _, desktop := range resp.GetDesktops() {
desktops = append(desktops, desktop)
}
return desktops, resp.GetNextPageToken(), nil
}

func (c *Client) CreateDynamicWindowsDesktop(ctx context.Context, desktop types.DynamicWindowsDesktop) (types.DynamicWindowsDesktop, error) {
switch desktop := desktop.(type) {
case *types.DynamicWindowsDesktopV1:
desktop, err := c.grpcClient.CreateDynamicWindowsDesktop(ctx, &dynamicwindows.CreateDynamicWindowsDesktopRequest{
Desktop: desktop,
})
return desktop, trace.Wrap(err)
default:
return nil, trace.BadParameter("unknown desktop type: %T", desktop)
}
}

func (c *Client) UpdateDynamicWindowsDesktop(ctx context.Context, desktop types.DynamicWindowsDesktop) (types.DynamicWindowsDesktop, error) {
switch desktop := desktop.(type) {
case *types.DynamicWindowsDesktopV1:
desktop, err := c.grpcClient.UpdateDynamicWindowsDesktop(ctx, &dynamicwindows.UpdateDynamicWindowsDesktopRequest{
Desktop: desktop,
})
return desktop, trace.Wrap(err)
default:
return nil, trace.BadParameter("unknown desktop type: %T", desktop)
}
}

func (c *Client) DeleteDynamicWindowsDesktop(ctx context.Context, name string) error {
_, err := c.grpcClient.DeleteDynamicWindowsDesktop(ctx, &dynamicwindows.DeleteDynamicWindowsDesktopRequest{
Name: name,
})
return trace.Wrap(err)
}
3 changes: 3 additions & 0 deletions api/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ const (
// KindWindowsDesktop is a Windows desktop host.
KindWindowsDesktop = "windows_desktop"

// KindDynamicWindowsDesktop is a dynamic Windows desktop host.
KindDynamicWindowsDesktop = "dynamic_windows_desktop"

// KindRecoveryCodes is a resource that holds users recovery codes.
KindRecoveryCodes = "recovery_codes"

Expand Down
Loading
Loading