Skip to content

Commit

Permalink
Add credentials class auth_method list and params
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoCoimbra committed Oct 4, 2023
1 parent 88eb487 commit 7574d09
Show file tree
Hide file tree
Showing 18 changed files with 1,457 additions and 800 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ repos:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-use-type-annotations
- repo: "https://github.com/pycqa/isort"
rev: 5.11.5
hooks:
- id: isort
# - repo: "https://github.com/pycqa/isort"
# rev: 5.11.5
# hooks:
# - id: isort
- repo: "https://github.com/psf/black"
rev: 22.3.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion creation/lib/cgWCreate.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def populate_standard_grid(self, rsl, auth_method, gridtype, entry_enabled, entr
self.add("cream_attributes", "$ENV(GLIDEIN_RSL)")
elif gridtype == "nordugrid" and rsl:
self.add("nordugrid_rsl", "$ENV(GLIDEIN_RSL)")
elif (gridtype == "condor") and ("project_id" in auth_method):
elif (gridtype == "condor") and ("project_id" in auth_method): # TODO: Check for credentials refactoring impact
self.add("+ProjectName", '"$ENV(GLIDEIN_PROJECT_ID)"')

# Force the copy to spool to prevent caching at the CE side
Expand Down
1 change: 1 addition & 0 deletions creation/lib/cvWParamDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,7 @@ def populate_common_descript(descript_dict, params):
descript_dict.add(proxy_attr_names[attr], repr(proxy_descript_values[attr]))

match_expr = params.match.match_expr
descript_dict.add("Parameters", repr(params.security.parameters))
descript_dict.add("MatchExpr", match_expr)


Expand Down
12 changes: 12 additions & 0 deletions creation/lib/cvWParams.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,11 @@ def init_defaults(self):
proxy_defaults["vm_type_fname"] = (None, "fname", "to specify a vm type without reconfig", None)
proxy_defaults["project_id"] = (None, "string", "OSG Project ID. Ex TG-12345", None)

# Parameter settings
parameter_defaults = cWParams.CommentedOrderedDict()
parameter_defaults["name"] = (None, "string", "parameter name", None)
parameter_defaults["value"] = (None, "string", "parameter value", None)

security_defaults = cWParams.CommentedOrderedDict()
security_defaults["proxy_selection_plugin"] = (
None,
Expand All @@ -355,6 +360,12 @@ def init_defaults(self):
"Each credential element contains",
proxy_defaults,
)
security_defaults["parameters"] = (
OrderedDict(),
"List of parameters",
"Each parameter element contains",
parameter_defaults,
)
security_defaults["security_name"] = (
None,
"frontend_name",
Expand Down Expand Up @@ -725,6 +736,7 @@ def get_xml_format(self):
"attrs": {"el_name": "attr", "subtypes_params": {"class": {}}},
"groups": {"el_name": "group", "subtypes_params": {"class": {}}},
"match_attrs": {"el_name": "match_attr", "subtypes_params": {"class": {}}},
"parameters": {"el_name": "parameter", "subtypes_params": {"class": {}}},
},
}

Expand Down
7 changes: 3 additions & 4 deletions factory/glideFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

from glideinwms.factory import (
glideFactoryConfig,
glideFactoryCredentials,
glideFactoryDowntimeLib,
glideFactoryEntryGroup,
glideFactoryInterface,
Expand All @@ -41,7 +40,7 @@
glideFactoryMonitoring,
glideFactoryPidLib,
)
from glideinwms.lib import cleanupSupport, condorMonitor, glideinWMSVersion, logSupport, util
from glideinwms.lib import cleanupSupport, condorMonitor, credentials, glideinWMSVersion, logSupport, util
from glideinwms.lib.condorMonitor import CondorQEdit, QueryError
from glideinwms.lib.pubCrypto import RSAKey

Expand Down Expand Up @@ -647,14 +646,14 @@ def _set_rlimit(soft_l=None, hard_l=None):
# available when the Entries startup
classads = {}
try:
classads = glideFactoryCredentials.get_globals_classads()
classads = credentials.get_globals_classads()
except Exception:
logSupport.log.error("Error occurred retrieving globals classad -- is Condor running?")

for classad_key in classads:
classad = classads[classad_key]
try:
glideFactoryCredentials.process_global(classad, glideinDescript, frontendDescript)
credentials.process_global(classad, glideinDescript, frontendDescript)
except:
logSupport.log.exception("Error occurred processing the globals classads: ")

Expand Down
12 changes: 6 additions & 6 deletions factory/glideFactoryConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import os.path
import shutil

from glideinwms.lib import pubCrypto, symCrypto
from glideinwms.lib import pubCrypto, symCrypto, credentials

############################################################
#
Expand Down Expand Up @@ -114,7 +114,7 @@ def __init__(self, entry_name, config_file, convert_function=repr):
############################################################


class GlideinKey:
class GlideinKey: # TODO: Check for credentials refactor
def __init__(self, pub_key_type, key_fname=None, recreate=False):
self.pub_key_type = pub_key_type
self.load(key_fname, recreate)
Expand Down Expand Up @@ -230,7 +230,7 @@ def load_old_rsa_key(self):

if self.data["OldPubKeyType"] is not None:
try:
self.data["OldPubKeyObj"] = GlideinKey(self.data["OldPubKeyType"], key_fname=self.backup_rsakey_fname)
self.data["OldPubKeyObj"] = credentials.RSAKey(path=self.backup_rsakey_fname)
except:
self.data["OldPubKeyType"] = None
self.data["OldPubKeyObj"] = None
Expand All @@ -256,9 +256,9 @@ def load_pub_key(self, recreate=False):
"""

if self.data["PubKeyType"] is not None:
self.data["PubKeyObj"] = GlideinKey(
self.data["PubKeyType"], key_fname=self.default_rsakey_fname, recreate=recreate
)
self.data["PubKeyObj"] = credentials.RSAKey(path=self.default_rsakey_fname)
if recreate:
self.data["PubKeyObj"].recreate()
else:
self.data["PubKeyObj"] = None
return
Expand Down
Loading

0 comments on commit 7574d09

Please sign in to comment.