From ad9a5b7e0a567ac6e28587f6c1f4f5271ecda7b3 Mon Sep 17 00:00:00 2001 From: Ray Lyon <36998292+skoobasteeve@users.noreply.github.com> Date: Sat, 5 Aug 2023 14:27:34 +0000 Subject: [PATCH] include template in package --- pyproject.toml | 2 +- src/successfactors_auth/auth.py | 6 ++++-- .../{ => templates}/sf_saml_template.xml | 0 3 files changed, 5 insertions(+), 3 deletions(-) rename src/successfactors_auth/{ => templates}/sf_saml_template.xml (100%) diff --git a/pyproject.toml b/pyproject.toml index 0546fae..55d4187 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "successfactors_auth" -version = "0.0.2" +version = "0.0.3" authors = [ { name="Ray Lyon", email="ray@raylyon.net" }, ] diff --git a/src/successfactors_auth/auth.py b/src/successfactors_auth/auth.py index 0013379..72f7ac4 100644 --- a/src/successfactors_auth/auth.py +++ b/src/successfactors_auth/auth.py @@ -33,9 +33,11 @@ token = sf_auth.auth( import base64 import requests import xmlsec -import importlib.resources from lxml import etree from datetime import datetime, timedelta +from importlib import resources as impresources + +from . import templates # Send POST request to SuccessFactors containing the generated @@ -104,7 +106,7 @@ def sign_assertion(xml_string, private_key): def auth(sf_url, sf_company_id, sf_oauth_client_id, sf_admin_user, sf_saml_private_key): - template_file = "sf_saml_template.xml" + template_file = (impresources.files(templates) / 'sf_saml_template.xml') # Generate SAML assertion XML from template file unsigned_assertion = generate_assertion(sf_url, diff --git a/src/successfactors_auth/sf_saml_template.xml b/src/successfactors_auth/templates/sf_saml_template.xml similarity index 100% rename from src/successfactors_auth/sf_saml_template.xml rename to src/successfactors_auth/templates/sf_saml_template.xml