This repository has been archived by the owner on Feb 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.py
92 lines (66 loc) · 2.84 KB
/
bootstrap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from os import getenv
import sys
from PyQt6.QtWidgets import (
QApplication,
)
from app.acme_directory_configuration_parser import ACMEDirectoryConfigurationParser
from app.pkcs_lib_finder import PKCS11LibFinder
from .pkcs import pkcs
from .appacme import ACME
import urllib.parse
from .page.welcome import WelcomePage
from .page.selectkey import SelectYubiKeyPage
from .page.logindigid import LoginWithDigiDPage
from .page.creatersakey import CreateRSAKeysPage
from .page.requestcert import RequestCertificatePage
from .page.savetoyubi import SaveToYubiKeyPage
from PyQt6.QtWidgets import (
QSizePolicy,
QWizard,
)
class MainWindow(QWizard):
def __init__(self, mypkcs, myacme, oidc_provider_base_url: urllib.parse.ParseResult):
super().__init__()
self.setWindowTitle("YubiKey Wizard")
self.resize(1024, 768)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
self.addPage(WelcomePage())
self.addPage(SelectYubiKeyPage(mypkcs))
self.addPage(CreateRSAKeysPage(mypkcs))
self.addPage(LoginWithDigiDPage(myacme, oidc_provider_base_url))
self.addPage(RequestCertificatePage(mypkcs, myacme))
self.addPage(SaveToYubiKeyPage(mypkcs))
# When the wizard has finished, close the application
self.finished.connect(QApplication.instance().quit)
class ApplicationBootstrapper:
DEFAULT_ACME_CA_SERVER_URL = "https://acme.proeftuin.uzi-online.rdobeheer.nl/directory"
DEFAULT_YUBIKEY_PIN = "123456"
DEFAULT_PROEFTUIN_OIDC_LOGIN_URL = "https://proeftuin.uzi-online.irealisatie.nl"
def _load_pkcs_wrapper(self) -> pkcs:
yubikey_pin = getenv(
"YUBIKEY_PIN",
)
# This will search default locations and fall back to the PYKCS11LIB environment variable
pkcslib = PKCS11LibFinder().find()
if not pkcslib:
raise RuntimeError("The PKCS library was not found. Application can not start up.")
pkcscls = pkcs(pykcs11lib=pkcslib, yubikey_pin=yubikey_pin)
return pkcscls
def start(self):
app = QApplication(sys.argv)
pkcscls: pkcs = self._load_pkcs_wrapper()
oidc_provider_url = urllib.parse.urlparse(
getenv("OIDC_PROVIDER_BASE_URL", self.DEFAULT_PROEFTUIN_OIDC_LOGIN_URL)
)
print(
f'Using OIDC base URL "{oidc_provider_url.geturl()}"',
)
acme_ca_server_url = urllib.parse.urlparse(getenv("ACME_SERVER_DIRECTORY_URL", self.DEFAULT_ACME_CA_SERVER_URL))
print(
f'Using ACME server directory URL "{acme_ca_server_url.geturl()}"',
)
directory_config = ACMEDirectoryConfigurationParser().parse(acme_ca_server_url)
acme = ACME(directory_config)
mainWindow = MainWindow(pkcscls, acme, oidc_provider_url)
mainWindow.show()
app.exec()