Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

WIP Work/possum #5

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
395d714
Possum authentication route
dividedmind Aug 9, 2016
028e1ad
Remove special classes for group, host, layer, user
dividedmind Aug 10, 2016
3cebc17
Move secret handling methods to Resource class
dividedmind Aug 10, 2016
094f683
Add password authentication
dividedmind Aug 11, 2016
f944c06
Remove new_from_netrc
dividedmind Aug 11, 2016
a9a606d
Drop functions referring to removed resources
dividedmind Aug 11, 2016
bb36054
Move public keys function to Role
dividedmind Aug 11, 2016
d0e3972
Remove _service_url
dividedmind Aug 11, 2016
31bfcaf
Remove resource permission methods
dividedmind Aug 11, 2016
a2ed263
Remove role grant/revoke methods
dividedmind Aug 11, 2016
b3829d9
Remove appliance_url remnants
dividedmind Aug 11, 2016
5f787ac
Integration test harness
dividedmind Aug 16, 2016
d3e0741
Feature environment
dividedmind Aug 16, 2016
7bd9209
Update group features
dividedmind Aug 16, 2016
90d2326
Add Role.info, adjust Role.members
dividedmind Aug 16, 2016
a76840a
Remove variable features
dividedmind Aug 16, 2016
bfb0ab1
Remove users features
dividedmind Aug 16, 2016
eada805
Modify permissions features to work with the loaded policy
dividedmind Aug 16, 2016
1aed91b
Resource check parameter is now 'resource', not 'resource_id'
dividedmind Aug 16, 2016
b4e296a
Make /artifacts mounted with /app
dividedmind Aug 16, 2016
b471f76
Pull by default on Jenkins
dividedmind Aug 16, 2016
81aad77
Or not
dividedmind Aug 16, 2016
ba27cef
Change Jenkins script defaults
dividedmind Aug 18, 2016
baa55d8
Add a wait for possum to the jenkins flow
dividedmind Aug 18, 2016
a32dd98
Archive artifacts correctly
dividedmind Aug 18, 2016
6eae79b
Throw an error on authentication error
dividedmind Aug 19, 2016
d748170
Add methods for listing resources and handling fq resources
dividedmind Aug 25, 2016
479a53a
Allow creating Role from a fqi
dividedmind Aug 25, 2016
54a44a3
Strip Role.public_keys output
dividedmind Aug 25, 2016
6216a78
Add Role.resource and Resource.role methods
dividedmind Aug 25, 2016
51402a3
Directory example
dividedmind Aug 25, 2016
86481d8
Add secrets example
dividedmind Aug 25, 2016
ac8b3cf
Return None when a secret doesn't exist
dividedmind Aug 25, 2016
e8befb8
Add authorization example
dividedmind Aug 25, 2016
4a49026
Add conjur.new_from_header
dividedmind Sep 9, 2016
9dbdfa2
Use user-provided header directly
dividedmind Sep 14, 2016
b3584b7
Correctly print secret keys in directory example
dividedmind Sep 14, 2016
2843146
Add authorization client example
dividedmind Sep 14, 2016
1ad2ab2
Set PYTHONPATH in Dockerfile
dividedmind Sep 14, 2016
5e65698
Add readme for the examples
dividedmind Sep 14, 2016
c58edab
Fix README to use docker-compose
dividedmind Sep 15, 2016
d6f9678
ignore data_key
kgilpin Sep 15, 2016
b9901e0
add to example README a bit
kgilpin Sep 15, 2016
66d6fe8
Merge pull request #6 from conjurinc/features/possum-examples
kgilpin Sep 15, 2016
fffa7ec
CON-3437 - Flask app example
dustinmm80 Sep 22, 2016
61b227b
Start on pet store example [CON-3437]
dustinmm80 Sep 23, 2016
b4dddc1
Finish petstore example [CON-3437]
dustinmm80 Sep 23, 2016
c13635b
Simulate users with different permissions [CON-3437]
dustinmm80 Sep 23, 2016
1667e85
Rename flaskapp -> petstore [CON-3437]
dustinmm80 Sep 23, 2016
7f34d2e
remove unused imports
dustinmm80 Sep 23, 2016
076cbfb
Remove 'update' privilege mention
dustinmm80 Sep 23, 2016
e74777d
Fix import path for conjur
dustinmm80 Sep 29, 2016
8061f8b
wip
kgilpin Oct 6, 2016
b5f013a
Updated the CLI and added example yaml
kgilpin Oct 11, 2016
676ca81
improve error reporting
kgilpin Oct 12, 2016
5d41385
use 'down' in stop script
kgilpin Oct 12, 2016
c1dcfb0
create demo directory
kgilpin Oct 12, 2016
5344fac
add proper ownership of the database
kgilpin Oct 12, 2016
e1ece37
Add --rotate option to 'login'
kgilpin Oct 12, 2016
d9f20ac
script to generate groups and users
kgilpin Oct 13, 2016
b572da8
print policy version and new API keys after load
kgilpin Oct 13, 2016
15e2353
exit with status 1 if the variable has no value
kgilpin Oct 13, 2016
30f72cf
Merge pull request #7 from conjurinc/possum-cli
dustinmm80 Oct 17, 2016
cba8c93
add missing return statement
kgilpin Oct 24, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
generated-policy.yml
data_key
artifacts
pytest.xml
htmlcov
Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WORKDIR /app
COPY requirements* /app/
RUN pip install -r requirements.txt -r requirements_dev.txt

COPY . /app
ENV PYTHONPATH /app

VOLUME /app
VOLUME /artifacts
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ of all classes and methods.
from conjur.config import config

# Set the conjur appliance url. This can also be provided
# by the CONJUR_APPLIANCE_URL environment variable.
config.appliance_url = 'https://conjur.example.com/api'
# by the POSSUM_URL environment variable.
config.url = 'https://possum.example'

# Set the (PEM) certificate file. This is also configurable with the
# CONJUR_CERT_FILE environment variable.
Expand Down
76 changes: 42 additions & 34 deletions conjur/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2014 Conjur Inc
# Copyright (C) 2014-2016 Conjur Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
Expand All @@ -17,17 +17,15 @@
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import base64
import os
import re
import requests

from config import Config
from api import API
from group import Group
from user import User
from host import Host
from layer import Layer
from resource import Resource
from role import Role
from variable import Variable
from exceptions import ConjurException

from config import config
Expand Down Expand Up @@ -57,47 +55,42 @@ def configure(**kwargs):
config.update(**kwargs)
return config


def new_from_netrc(netrc_file=None, configuration=None):
"""
Create a `conjur.API` instance using an identity loaded from netrc. This method
uses the identity stored for the host `config.authn_url`.

`netrc_file` is an alternative path to the netrc formatted file. Defaults
to ~/.netrc on unixy systems.

`configuration` is a `conjur.Config` instance used to determine the host
in the netrc file, and also passed to the `conjur.new_from_key` method to
create the API instance using the identity.
"""
import netrc

configuration = _config(configuration)
auth = netrc.netrc(netrc_file).authenticators(configuration.authn_url)
if auth is None:
raise ValueError("No authenticators found for authn_url '%s' in %s" % (
configuration.authn_url,
(netrc_file or '~/.netrc')
))
login, _, api_key = auth
return new_from_key(login, api_key, configuration)


def new_from_key(login, api_key, configuration=None):
"""
Create a `conjur.API` instance that will authenticate on demand as the identity given
by `login` and `api_key`.

`login` is the identity of the Conjur user or host to authenticate as.

`api_key` is the api key *or* password to use when authenticating.
`api_key` is the api key to use when authenticating.

`configuration` is a `conjur.Config` instance for the api. If not given the global
`Config` instance (`conjur.config`) will be used.
"""

return API(credentials=(login, api_key), config=_config(configuration))

def new_from_password(login, password, configuration=None):
"""
Create a `conjur.API` instance that will authenticate immediately (to
exchange the password for the API key) as the identity given by `login`
and `api_key`.

`login` is the identity of the Conjur user or host to authenticate as.

`password` is the password to use when authenticating.

`configuration` is a `conjur.Config` instance for the api. If not given the global
`Config` instance (`conjur.config`) will be used. Note it needs to be
set up correctly before using this function.
"""
configuration = _config(configuration)
url = "%s/authn/%s/login" % (configuration.url, configuration.account)
response = requests.get(url, auth=(login, password), verify=configuration.verify)
if response.status_code != 200:
raise ConjurException("Authentication error: {} {}".format(response.status_code, response.reason))
api_key = response.text
return new_from_key(login, api_key, configuration)

def new_from_token(token, configuration=None):
"""
Expand All @@ -114,7 +107,22 @@ def new_from_token(token, configuration=None):
"""
return API(token=token, config=_config(configuration))

def new_from_header(authorization_header, configuration=None):
"""
Create a `conjur.API` instance based on an Authorization header.

This is mostly useful for proxies, authenticators and wrappers which
forward Authorization header supplied by the client.

`authorization_header` is the Authorization header contents,
eg. `Token token="<base64d token>"`.

`configuration` is a conjur.Config instance for the api. If not given, the global Config
instance (`conjur.config`) will be used.
"""
return API(header=authorization_header, config=_config(configuration))

__all__ = (
'config', 'Config', 'Group', 'API', 'User', 'Host', 'Layer', 'Resource', 'Role', 'Variable',
'new_from_key', 'new_from_netrc', 'new_from_token', 'configure', 'ConjurException'
)
)
Loading