-
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
ideahitme
committed
May 28, 2017
1 parent
089bed8
commit 8c2f4b7
Showing
11 changed files
with
239 additions
and
75 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
package authorizer | ||
|
||
var _ Authorizer = &Casbin{} | ||
var _ ResourceAuthorizer = &ResourceCasbin{} | ||
var _ NonResourceAuthorizer = &NonResourceCasbin{} |
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,19 @@ | ||
package authorizer | ||
|
||
import "github.com/ideahitme/k8s-api-webhook/authz/unversioned" | ||
|
||
// ResourceUnauthorizer is authorizer which does not allow access to any of the resources | ||
type ResourceUnauthorizer struct{} | ||
|
||
// NonResourceUnauthorizer is authorizer which does not allow access to any of the non-resources | ||
type NonResourceUnauthorizer struct{} | ||
|
||
// IsAuthorized always returns false | ||
func (ResourceUnauthorizer) IsAuthorized(*unversioned.UserSpec, *unversioned.ResourceSpec) (bool, error) { | ||
return false, nil | ||
} | ||
|
||
// IsAuthorized always returns false | ||
func (NonResourceUnauthorizer) IsAuthorized(*unversioned.UserSpec, *unversioned.NonResourceSpec) (bool, error) { | ||
return false, nil | ||
} |
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,14 @@ | ||
package authorizer | ||
|
||
import "testing" | ||
import "github.com/stretchr/testify/assert" | ||
|
||
func TestUnauthorizer(t *testing.T) { | ||
allowed, err := NonResourceUnauthorizer{}.IsAuthorized(nil, nil) | ||
assert.False(t, allowed, "always false") | ||
assert.Nil(t, err, "error should be nil") | ||
|
||
allowed, err = ResourceUnauthorizer{}.IsAuthorized(nil, nil) | ||
assert.False(t, allowed, "always false") | ||
assert.Nil(t, err, "error should be nil") | ||
} |
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
Oops, something went wrong.