Merge pull request #8 from thedac/actions
Show service provider metadata action
This commit is contained in:
commit
4e1cca4895
|
@ -141,6 +141,7 @@ The key PEM file is the resource file for sp-private-key.pem. The certificate
|
|||
PEM data will be placed in an XML document and will become the
|
||||
sp-signing-keyinfo.xml resource file.
|
||||
|
||||
```
|
||||
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
|
||||
<ds:X509Data>
|
||||
<ds:X509Certificate>
|
||||
|
@ -153,7 +154,7 @@ sp-signing-keyinfo.xml resource file.
|
|||
</ds:X509Certificate>
|
||||
</ds:X509Data>
|
||||
</ds:KeyInfo>
|
||||
|
||||
```
|
||||
|
||||
Set the protocol. This must match the protocol used in the post-deployment
|
||||
configuration steps. We recommend the protocol "mapped."
|
||||
|
@ -177,7 +178,7 @@ Attach resources
|
|||
|
||||
Get keystones SP metadata XML and exchange it with your idP
|
||||
|
||||
juju run --unit keystone/0 "cat /etc/apache2/mellon/sp-meta.keystone-saml-mellon.xml"
|
||||
juju run-action keystone-saml-mellon/0 get-sp-metadata
|
||||
|
||||
# Post-deployment Configuration
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
get-sp-metadata:
|
||||
description: |
|
||||
Display the Service Provider metadata to be exchanged with the Identity
|
||||
Provider.
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/local/sbin/charm-env python3
|
||||
# Copyright 2019 Canonical Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
|
||||
|
||||
SP_METADATA_FILE = "/etc/apache2/mellon/sp-meta.keystone-saml-mellon.xml"
|
||||
|
||||
|
||||
def get_sp_metadata(*args):
|
||||
if not os.path.exists(SP_METADATA_FILE):
|
||||
return hookenv.action_fail(
|
||||
"The SP metadata file {} does not exist"
|
||||
.format(SP_METADATA_FILE))
|
||||
sp_metadata = ""
|
||||
# By stripping double new lines and tabs we get human readable xml
|
||||
# Otherwise, show-action-status is a garbled mess
|
||||
with open(SP_METADATA_FILE, 'rt') as f:
|
||||
for line in f.readlines():
|
||||
line = line.replace("\t", " ")
|
||||
if line.strip(" ") == "\n":
|
||||
continue
|
||||
sp_metadata += line
|
||||
return hookenv.action_set({"output": sp_metadata})
|
||||
|
||||
|
||||
ACTIONS = {
|
||||
'get-sp-metadata': get_sp_metadata,
|
||||
}
|
||||
|
||||
|
||||
def main(args):
|
||||
action_name = os.path.basename(args[0])
|
||||
try:
|
||||
action = ACTIONS[action_name]
|
||||
except KeyError:
|
||||
return 'Action {} undefined'.format(action_name)
|
||||
else:
|
||||
try:
|
||||
action(args)
|
||||
except Exception as e:
|
||||
hookenv.action_fail(str(e))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main(sys.argv))
|
|
@ -0,0 +1 @@
|
|||
actions.py
|
|
@ -5,4 +5,3 @@ options:
|
|||
use_venv: True
|
||||
include_system_packages: True
|
||||
packages: ['python3-lxml', 'python3-cryptography']
|
||||
repo: https://github.com/dshcherb/charm-keystone-saml-mellon
|
||||
|
|
|
@ -2,7 +2,7 @@ charm-tools>=2.4.4
|
|||
requests>=2.18.4
|
||||
mock>=1.2
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
os-testr>=0.4.1
|
||||
stestr>=2.2.0
|
||||
python-keystoneclient>=1.7.1
|
||||
python-swiftclient
|
||||
git+https://github.com/openstack-charmers/zaza.git#egg=zaza;python_version>='3.0'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Classic charm: ./tox.ini
|
||||
# Source charm: ./src/tox.ini
|
||||
# This file is managed centrally by release-tools and should not be modified
|
||||
# within individual charm repos.
|
||||
[tox]
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# Lint and unit test requirements
|
||||
flake8
|
||||
os-testr>=0.4.1
|
||||
stestr>=2.2.0
|
||||
charms.reactive
|
||||
mock>=1.2
|
||||
nose>=1.3.7
|
||||
coverage>=3.6
|
||||
lxml
|
||||
cryptography
|
||||
git+https://github.com/openstack/charms.openstack.git#egg=charms-openstack
|
||||
|
|
6
tox.ini
6
tox.ini
|
@ -24,17 +24,17 @@ commands =
|
|||
[testenv:py3]
|
||||
basepython = python3
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py35]
|
||||
basepython = python3.5
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:py36]
|
||||
basepython = python3.6
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
commands = ostestr {posargs}
|
||||
commands = stestr run {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
basepython = python3
|
||||
|
|
Loading…
Reference in New Issue