-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
1 parent
c426c12
commit a7566e9
Showing
4 changed files
with
92 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package authproviders | ||
|
||
import ( | ||
"fmt" | ||
|
||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api" | ||
) | ||
|
||
//GetToken gets the token from auth provider config | ||
func GetToken(ap *clientcmdapi.AuthProviderConfig) (string, error) { | ||
switch ap.Name { | ||
case "gcp": | ||
return ap.Config["access-token"], nil | ||
case "azure": | ||
return ap.Config["access-token"], nil | ||
case "oidc": | ||
return ap.Config["id-token"], nil | ||
} | ||
|
||
return "", fmt.Errorf("unsupported auth provider %s", ap.Name) | ||
} |
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,18 @@ | ||
package k8s | ||
|
||
import ( | ||
authorizationv1 "k8s.io/api/authorization/v1" | ||
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
//WhatCanI runs self subject review request | ||
func WhatCanI(kubeclient kubernetes.Interface) error { | ||
sar := &authorizationv1.SelfSubjectRulesReview{ | ||
Spec: authorizationv1.SelfSubjectRulesReviewSpec{ | ||
Namespace: "default", | ||
}, | ||
} | ||
|
||
_, err := kubeclient.AuthorizationV1().SelfSubjectRulesReviews().Create(sar) | ||
return err | ||
} |
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