containers: mock oauth container

Add a mock oauth container to simulate
the openshift SSO offline_token
This commit is contained in:
Gianluca Zuccarelli 2021-11-11 20:03:21 +00:00 committed by Ondřej Budai
parent af9cca1b50
commit 44017890ca
3 changed files with 44 additions and 0 deletions

28
containers/fauxauth/fauxauth.py Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env python3
import argparse, subprocess
def launch_server(address, port, certdir):
cmd = [
"/usr/libexec/osbuild-composer/osbuild-mock-openid-provider",
"-a", str.join(":", [address, port]),
"-rsaPubPem", f"{certdir}/client-crt.pem",
"-rsaPem", f"{certdir}/client-key.pem",
]
print("Running oath server")
return subprocess.run(
cmd,
cwd="/usr/libexec/osbuild-composer",
stdin=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("-a", "--address", help="IP address for the server", type=str, default="localhost")
parser.add_argument("-p", "--port", help="Port for the server", type=str, default="8080")
parser.add_argument("-c", "--certdir", help="The location dir of the certs", type=str, default="/etc/osbuild-composer")
args = parser.parse_args()
launch_server(args.address, args.port, args.certdir)
if __name__ == "__main__":
main()