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

fix(jans-linux-setup): Store fido2 authenticator_cert in DB #10697

Merged
merged 3 commits into from
Jan 22, 2025
Merged
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
25 changes: 11 additions & 14 deletions jans-linux-setup/jans_setup/setup_app/installers/fido.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def install(self):
def generate_configuration(self):
Config.fido_document_certs_inum = str(uuid.uuid4())
Config.fido_document_tocs_inum = str(uuid.uuid4())
Config.Apple_WebAuthn_Root_CA_inum = str(uuid.uuid4())
self.fido_document_creation_date = self.get_ldap_time()

def render_import_templates(self):
Expand All @@ -74,6 +75,15 @@ def render_import_templates(self):

Config.templateRenderingDict['fido_document_tocs_base64'] = self.generate_base64_file(self.source_files[2][0], 1)
Config.templateRenderingDict['fido_document_certs_base64'] = self.generate_base64_file(self.source_files[3][0], 1)
Config.templateRenderingDict['Apple_WebAuthn_Root_CA_base64'] = self.generate_base64_file(self.source_files[1][0], 1)

for f in ('yubico-u2f-ca-cert.crt', 'HyperFIDO_CA_Cert_V1.pem', 'HyperFIDO_CA_Cert_V2.pem'):
src = os.path.join(Config.install_dir, 'static/fido2/authenticator_cert/', f)
doc_var, _ = os.path.splitext(f)
doc_var = doc_var.replace('-','_')
setattr(Config, doc_var + '_inum', str(uuid.uuid4()))
Config.templateRenderingDict[doc_var + '_base64'] = self.generate_base64_file(src, 1)


for tmp_ in (self.ldif_fido2, self.ldif_fido2_documents):
self.renderTemplateInOut(tmp_, self.template_folder, self.output_folder)
Expand All @@ -83,29 +93,16 @@ def render_import_templates(self):


def create_folders(self):
for d in ('authenticator_cert', 'mds/cert', 'mds/toc', 'server_metadata'):
for d in ('mds/cert', 'mds/toc', 'server_metadata'):
dpath = os.path.join(self.fido2ConfigFolder, d)
self.run([paths.cmd_mkdir, '-p', dpath])

def copy_static(self):
# Fido2 authenticator certs
target_dir = os.path.join(self.fido2ConfigFolder, 'authenticator_cert')
for f in ('yubico-u2f-ca-cert.crt', 'HyperFIDO_CA_Cert_V1.pem', 'HyperFIDO_CA_Cert_V2.pem'):
src = os.path.join(Config.install_dir, 'static/fido2/authenticator_cert/', f)
self.copyFile(src, target_dir)

#copy fido2 server metadata
src_dir = os.path.join(Config.install_dir, 'static/fido2/server_metadata')
trgt_dir = os.path.join(self.fido2ConfigFolder, 'server_metadata')
self.copy_tree(src_dir, trgt_dir, ignore='.dontdelete')

# copy Apple_WebAuthn_Root_CA
if os.path.exists(self.source_files[1][0]):
target_dir = os.path.join(self.fido2ConfigFolder, 'authenticator_cert')
self.run([paths.cmd_mkdir, '-p', target_dir])
self.copyFile(self.source_files[1][0], target_dir)

# copy external files

def service_post_install_tasks(self):
base.current_app.ConfigApiInstaller.install_plugin('fido2')
53 changes: 53 additions & 0 deletions jans-linux-setup/jans_setup/templates/jans-fido2/docuemts.ldif
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,56 @@ jansEnabled: true
jansFilePath: %(fido_document_tocs_dir)s
jansLevel: 0
jansService: Fido2 MDS

dn: inum=%(yubico_u2f_ca_cert_inum)s,ou=document,o=jans
objectClass: top
objectClass: jansDocument
creationDate: %(fido_document_creation_date)s
description: yubico-u2f-ca-cert.crt
displayName: yubico-u2f-ca-cert.crt
document: %(yubico_u2f_ca_cert_base64)s
inum: %(yubico_u2f_ca_cert_inum)s
jansEnabled: true
jansFilePath: %(fido_document_tocs_dir)s
jansLevel: 0
jansService: Fido2 MDS

dn: inum=%(HyperFIDO_CA_Cert_V1_inum)s,ou=document,o=jans
objectClass: top
objectClass: jansDocument
creationDate: %(fido_document_creation_date)s
description: HyperFIDO_CA_Cert_V1.pem
displayName: HyperFIDO_CA_Cert_V1.pem
document: %(HyperFIDO_CA_Cert_V1_base64)s
inum: %(HyperFIDO_CA_Cert_V1_inum)s
jansEnabled: true
jansFilePath: %(fido_document_tocs_dir)s
jansLevel: 0
jansService: Fido2 MDS

dn: inum=%(HyperFIDO_CA_Cert_V2_inum)s,ou=document,o=jans
objectClass: top
objectClass: jansDocument
creationDate: %(fido_document_creation_date)s
description: HyperFIDO_CA_Cert_V2.pem
displayName: HyperFIDO_CA_Cert_V2.pem
document: %(HyperFIDO_CA_Cert_V2_base64)s
inum: %(HyperFIDO_CA_Cert_V2_inum)s
jansEnabled: true
jansFilePath: %(fido_document_tocs_dir)s
jansLevel: 0
jansService: Fido2 MDS

dn: inum=%(Apple_WebAuthn_Root_CA_inum)s,ou=document,o=jans
objectClass: top
objectClass: jansDocument
creationDate: %(fido_document_creation_date)s
description: Apple_WebAuthn_Root_CA.pem
displayName: Apple_WebAuthn_Root_CA.pem
document: %(Apple_WebAuthn_Root_CA_base64)s
inum: %(Apple_WebAuthn_Root_CA_inum)s
jansEnabled: true
jansFilePath: %(fido_document_tocs_dir)s
jansLevel: 0
jansService: Fido2 MDS

Loading