Skip to content

Commit

Permalink
Fully remove local support for environments and user repository as it…
Browse files Browse the repository at this point in the history
… does not make sense because Impersonation isn't supported at Windows by design.
  • Loading branch information
blaubaer committed Aug 26, 2024
1 parent a13f8a0 commit ffffdfa
Show file tree
Hide file tree
Showing 34 changed files with 209 additions and 1,140 deletions.
2 changes: 1 addition & 1 deletion cmd/bifroest/main_linux.go → cmd/bifroest/main_unix.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package main

Expand Down
2 changes: 1 addition & 1 deletion pkg/authorization/local-authorizer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package authorization

Expand Down
2 changes: 1 addition & 1 deletion pkg/authorization/local.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package authorization

Expand Down
2 changes: 1 addition & 1 deletion pkg/configuration/authorization-local.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package configuration

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//go:build linux
//go:build unix

package configuration

import (
"testing"

"github.com/echocat/slf4g/sdk/testlog"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/crypto"
"github.com/engity-com/bifroest/pkg/template"
"testing"
)

func TestConfiguration_UnmarshalYAML(t *testing.T) {
Expand All @@ -33,7 +35,7 @@ func TestConfiguration_UnmarshalYAML(t *testing.T) {
name: "required-set",
yaml: `flows:
- name: foo
authorization:
authorization:
type: oidcDeviceAuth
issuer: https://foo-bar
clientId: anId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
//go:build linux
//go:build unix

package configuration

import (
"github.com/engity-com/bifroest/pkg/template"
"gopkg.in/yaml.v3"

"github.com/engity-com/bifroest/pkg/template"
)

var (
Expand Down
46 changes: 0 additions & 46 deletions pkg/configuration/environment-local-dispose_windows.go

This file was deleted.

2 changes: 2 additions & 0 deletions pkg/configuration/environment-local.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix

package configuration

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//go:build linux
//go:build unix

package configuration

import (
"fmt"

"gopkg.in/yaml.v3"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/template"
"github.com/engity-com/bifroest/pkg/user"
"gopkg.in/yaml.v3"
)

var (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package configuration

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build linux
//go:build unix

package configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ package configuration

import (
"fmt"

"gopkg.in/yaml.v3"

"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/template"
"github.com/engity-com/bifroest/pkg/user"
"gopkg.in/yaml.v3"
)

type UserRequirementTemplate struct {
Expand Down
86 changes: 0 additions & 86 deletions pkg/configuration/user-requirement-template_windows.go

This file was deleted.

2 changes: 2 additions & 0 deletions pkg/environment/local-repository.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unix

package environment

import (
Expand Down
52 changes: 52 additions & 0 deletions pkg/environment/local-token.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
//go:build unix

package environment

import (
"github.com/engity-com/bifroest/pkg/common"
"github.com/engity-com/bifroest/pkg/user"
)

type localToken struct {
User localTokenUser `json:"user"`
PortForwardingAllowed bool `json:"portForwardingAllowed"`
}

type localTokenUser struct {
Name string `json:"name,omitempty"`
Uid *user.Id `json:"uid,omitempty"`
Managed bool `json:"managed,omitempty"`
DeleteOnDispose bool `json:"deleteOnDispose,omitempty"`
DeleteHomeDirOnDispose bool `json:"deleteHomeDirOnDispose,omitempty"`
KillProcessesOnDispose bool `json:"killProcessesOnDispose,omitempty"`
}

func (this *LocalRepository) newLocalToken(u *user.User, req Request, userIsManaged bool) (*localToken, error) {
fail := func(err error) (*localToken, error) {
return nil, err
}

portForwardingAllowed, err := this.conf.PortForwardingAllowed.Render(req)
if err != nil {
return fail(err)
}

deleteOnDispose, err := this.conf.Dispose.DeleteManagedUser.Render(req)
if err != nil {
return fail(err)
}
deleteHomeDirOnDispose, err := this.conf.Dispose.DeleteManagedUserHomeDir.Render(req)
if err != nil {
return fail(err)
}
killProcessesOnDispose, err := this.conf.Dispose.KillManagedUserProcesses.Render(req)
if err != nil {
return fail(err)
}

return &localToken{
localTokenUser{
u.Name,
common.P(u.Uid),
userIsManaged,
deleteOnDispose && userIsManaged,
deleteHomeDirOnDispose && deleteOnDispose && userIsManaged,
killProcessesOnDispose && userIsManaged,
},
portForwardingAllowed,
}, nil
}
53 changes: 0 additions & 53 deletions pkg/environment/local-token_linux.go

This file was deleted.

Loading

0 comments on commit ffffdfa

Please sign in to comment.