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
3 changed files
with
50 additions
and
2 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,23 @@ | ||
|
||
|
||
class TrivialTrue(object): | ||
def __init__(self, options): | ||
self.options = options | ||
|
||
def can_haz(self, target, credentials): | ||
return True | ||
|
||
|
||
class SimpleMatch(object): | ||
def __init__(self, options): | ||
self.options = options | ||
|
||
def can_haz(self, target, credentials): | ||
"""Check whether key-values in target are present in credentials.""" | ||
# TODO(termie): handle ANDs, probably by providing a tuple instead of a | ||
# string | ||
for requirement in target: | ||
key, match = requirement.split(':', 1) | ||
check = credentials.get(key) | ||
if check == match: | ||
return True |
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 @@ | ||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
|
||
# the catalog interfaces | ||
|
||
import uuid | ||
|
||
from keystonelight import utils | ||
|
||
|
||
class Manager(object): | ||
def __init__(self, options): | ||
self.options = options | ||
self.driver = utils.import_object(options['policy_driver'], | ||
options=options) | ||
|
||
def can_haz(self, context, target, credentials): | ||
"""Check whether the given creds can perform action on target.""" | ||
return self.driver.can_haz(target, credentials) |