forked from mesosphere/traefik-forward-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
575 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
) | ||
|
||
var ErrUserDataStore = errors.New("userdata storage error") | ||
|
||
func UserDataStoreError(msg string) error { | ||
return fmt.Errorf("%w: %s", ErrUserDataStore, msg) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package v1alpha1 | ||
|
||
import "net/http" | ||
|
||
type UserInfoInterface interface { | ||
Clear(r *http.Request, w http.ResponseWriter) error | ||
Get(r *http.Request) (*UserInfo, error) | ||
Save(r *http.Request, w http.ResponseWriter, info *UserInfo) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package v1alpha1 | ||
|
||
type UserInfo struct { | ||
Username string | ||
Email string | ||
Groups []string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,14 +139,12 @@ func TestRBACAuthorizer_Authorize(t *testing.T) { | |
} | ||
} | ||
|
||
|
||
func TestRBACAuthorizer_Authorize2(t *testing.T) { | ||
test := testCase{ | ||
|
||
user: authorization.User{Name: "[email protected]", Groups:[]string{"oidc:chemists"}}, | ||
url: "/ops/portal/grafana/public/fonts/roboto/RxZJdnzeo3R5zSexge8UUVtXRa8TVwTICgirnJhmVJw.woff2", | ||
should: allow, | ||
|
||
user: authorization.User{Name: "[email protected]", Groups: []string{"oidc:chemists"}}, | ||
url: "/ops/portal/grafana/public/fonts/roboto/RxZJdnzeo3R5zSexge8UUVtXRa8TVwTICgirnJhmVJw.woff2", | ||
should: allow, | ||
} | ||
|
||
role := makeRole("grafana-admin", []string{"*"}, []string{"/ops/portal/grafana", "/ops/portal/grafana/*"}) | ||
|
@@ -157,4 +155,4 @@ func TestRBACAuthorizer_Authorize2(t *testing.T) { | |
|
||
assert.NilError(t, err) | ||
assert.Equal(t, result, test.should) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"fmt" | ||
k8s "k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"os" | ||
) | ||
|
||
const ( | ||
KubeConfigEnv = "KUBECONFIG" | ||
) | ||
|
||
// GetClientSet will attempt to get an external cluster configuration if the KUBECONFIG environment | ||
// variable is set. Otherwise will attempt to get an in-cluster configuration. | ||
func GetClientSet() (*k8s.Clientset, error) { | ||
configPath := os.Getenv(KubeConfigEnv) | ||
var config *rest.Config | ||
var err error | ||
if configPath != "" { | ||
config, err = clientcmd.BuildConfigFromFlags("", configPath) | ||
if err != nil { | ||
return nil, fmt.Errorf("error getting rest config from %s: %w", configPath, err) | ||
} | ||
} else { | ||
config, err = rest.InClusterConfig() | ||
if err != nil { | ||
return nil, fmt.Errorf("error getting in cluster configuration: %w", err) | ||
} | ||
} | ||
|
||
clientset, err := k8s.NewForConfig(config) | ||
if err != nil { | ||
return nil, fmt.Errorf("error getting clientset from config: %w", err) | ||
} | ||
return clientset, nil | ||
} |
Oops, something went wrong.