Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add credentials folder and .gitignore, and move secrets to that folder #54

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
163 changes: 163 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
tmp/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## IdP customizations for UW
# IdP customizations for UW

These files are customization configuration for the UW Shib IdP.

Presently they are for reference only. Not meant to be installed.
Our idp servers are at:

Jim Fox
fox@uw.edu
- idp1[1-6].s.uw.edu

## File Details

There are five configuration files that are dynamically managed by scripts.
These scan the SPRegistry database for updates and rebuild the files as needed.
Expand All @@ -20,4 +20,3 @@ local-bin/filter_scan.py manages
conf/saml-nameid-exceptions.xml using conf/saml-nameid-exceptions.j2

Both Python scripts are called by local-bin/refresh_uw.sh.

14 changes: 14 additions & 0 deletions credentials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Credentials

Important: Don't run `git add -f` on this folder. Only use `git add`.

This contains the credentials folder we store on the idp server.

At a minimum, this folder should contain:

File | Description
------- | ---
db.yaml | DB credentials for spregistry and other DBs. Used by Python scripts.
iamtools-client-cert.pem | The public key for the DB
iamtools-client-key.pem | The private key for the DB
iamtools-server-ca.pem | The public key for the CA, used for DB connections
26 changes: 26 additions & 0 deletions credentials/db.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# setting for local DB
tgtid_db:
db_host: "localhost"
db_name: "idp"
db_user: "someuser"
db_pass: "somepass"

# setting for iam-tools-test spreg
spreg_db_TEST:
db_host: "somehost"
db_name: "spregistry_eval"
db_user: "someuser"
db_pass: "somepass"
db_sslrootcert: "/data/local/idp/credentials/iamtools-server-ca.pem"
db_sslcert: "/data/local/idp/credentials/iamtools-client-cert.pem"
db_sslkey: "/data/local/idp/credentials/iamtools-client-key.pem"

# setting for iam-tools spreg
spreg_db:
db_host: "somehost"
db_name: "spregistry"
db_user: "someuser"
db_pass: "somepass"
db_sslrootcert: "/data/local/idp/credentials/iamtools-server-ca.pem"
db_sslcert: "/data/local/idp/credentials/iamtools-client-cert.pem"
db_sslkey: "/data/local/idp/credentials/iamtools-client-key.pem"
12 changes: 6 additions & 6 deletions local-bin/py-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
psycopg2
psycopg2-binary
lxml
jinja2
pep8
requests
psycopg2-binary==2.9.1
lxml==4.6.3
jinja2==3.0.1
pep8==1.7.1
requests==2.25.1
pyyaml==6.0.1
39 changes: 14 additions & 25 deletions local-bin/spreg_conf.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
"""Contains config values used by the scripts in this folder."""

idp_base = '/data/local/idp/'

tgtid_db = {
"db_host": "localhost",
"db_name": "idp",
"db_user": "shib",
"db_pass": "spud123",
}
import yaml

# setting for iam-tools-test spreg
spreg_db_TEST = {
'db_host': 'iamdbdev20',
'db_name': 'spregistry',
'db_user': 'spreg1',
'db_pass': 'ae500169-e8b9-4945-ba56-10d59d380067',
}

# setting for iam-tools spreg
spreg_db = {
'db_host': 'iamdb21',
'db_name': 'spregistry',
'db_user': 'spreg1',
'db_pass': '47dafbe2-2c28-4a16-a549-591285c62e5a',
}
idp_base = '/data/local/idp/'

creds_dir = idp_base + "credentials/"
conf_dir = idp_base + 'conf/'
metadata_dir = idp_base + 'rp-metadata/'
metadata_cache_dir = idp_base + '/rp-metadata-cache/'
Expand All @@ -39,6 +20,16 @@
metadata_id = 'uwrp'
metadata_min_rows = 500

# Prefer this config object for creds
spreg_creds = None
with open(creds_dir + "db.yaml", "r", encoding="utf-8") as creds_file:
spreg_creds = yaml.safe_load(creds_file)

# Shortcuts for backward compatibility, deprecated
tgtid_db = spreg_creds["tgtid_db"]
spreg_db_TEST = spreg_creds["spreg_db_TEST"]
spreg_db = spreg_creds["spreg_db"]

# old config
idp_conf_files = {
'groups': [
Expand Down Expand Up @@ -95,5 +86,3 @@
'xsi:schemaLocation="urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd ' \
'org.geant.idpextension.oidc.attribute.filter classpath:/schema/idp-oidc-extension-afp.xsd" >'
filter_footer_xml = '</AttributeFilterPolicyGroup>'


37 changes: 15 additions & 22 deletions local-bin/spreg_conf_4.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
"""Contains config values used by the scripts in this folder.

idp_base = '/data/local/idp/'

tgtid_db = {
"db_host": "localhost",
"db_name": "idp",
"db_user": "shib",
"db_pass": "spud123",
}
TODO: De-duplicate this file with the other conf.py file."""

# setting for iam-tools-test spreg
spreg_db_TEST = {
'db_host': 'iamdbdev01',
'db_name': 'spregistry',
'db_user': 'spreg1',
'db_pass': 'ae500169-e8b9-4945-ba56-10d59d380067',
}
import yaml

# setting for iam-tools spreg
spreg_db = {
'db_host': 'iamdb21',
'db_name': 'spregistry',
'db_user': 'spreg1',
'db_pass': '47dafbe2-2c28-4a16-a549-591285c62e5a',
}
idp_base = '/data/local/idp/'

creds_dir = idp_base + "credentials/"
conf_dir = idp_base + '/conf/'
filter_dir = idp_base + '/conf/'
metadata_dir = idp_base + '/rp-metadata/'
Expand All @@ -32,6 +15,16 @@
archive_dir = idp_base + 'archive/'
template_dir = conf_dir

# Prefer this config object for creds
spreg_creds = None
with open(creds_dir + "db.yaml", "r") as creds_file:
spreg_creds = yaml.safe_load(creds_file)

# Shortcuts for backward compatibility, deprecated
tgtid_db = spreg_creds["tgtid_db"]
spreg_db_TEST = spreg_creds["spreg_db_TEST"]
spreg_db = spreg_creds["spreg_db"]

idp_conf_files = {
'groups': [
{'type': 'metadata', 'id':'uwrp', 'dir': 'metadata', 'filename': 'UW-rp-metadata.xml', 'min_rows': 500},
Expand Down