Skip to content
Closed
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
48 changes: 0 additions & 48 deletions .github/workflows/auto-review.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/automerge.yml

This file was deleted.

81 changes: 81 additions & 0 deletions examples/nsscache-scim.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Example nsscache.conf for SCIM source

[DEFAULT]

# Use SCIM as the data source
source = scim

# Default NSS data cache module name
cache = files

# NSS maps to be cached
maps = passwd, group, sshkey

# Directory where cache files will be stored
files_dir = /tmp/nsscache

# Directory to store our update/modify timestamps
timestamp_dir = /tmp/nsscache/nsscache-timestamps

lockfile = /tmp/nsscache/nsscache.lock

##
# SCIM source configuration
##

# SCIM base URL
scim_base_url = https://example.com/scim

# SCIM authentication token (replace with actual token)
scim_auth_token = <token>

# (Optional) SCIM endpoints
scim_users_endpoint = Users
scim_groups_endpoint = Groups

# (Optional) SCIM url query parameters
# Special characters (spaces, quotes, etc.) will be automatically URL encoded
scim_users_parameters = groups=admin&filter=active eq "true"
scim_groups_parameters = filter=displayName eq "users" or displayName eq "admin"

# (Optional) SCIM options
scim_timeout = 60
scim_verify_ssl = True

##
# SCIM map configuration
##

# (Optional) All SCIM path field mapping configuration
# "/" seperated from the SCIM response.
# The "Resources/" is already prefixed and should be left off values.


[passwd]

scim_path_username = urn:example:params:scim:schemas:extension:User/userName
scim_path_uid = urn:example:params:scim:schemas:extension:User/userId
scim_path_gid = urn:example:params:scim:schemas:extension:User/groupId
scim_path_home_directory = urn:example:params:scim:schemas:extension:User/homeDirectory
scim_path_login_shell = urn:example:params:scim:schemas:extension:User/loginShell

# (Optional) Default shell if not specified for the user
scim_default_shell = /bin/bash

[sshkey]

scim_path_username = urn:example:params:scim:schemas:extension:User/userName
scim_path_ssh_keys = urn:example:params:scim:schemas:extension:User/sshKeys

[group]

scim_path_username = urn:example:params:scim:schemas:extension:User/userName
scim_path_gid = urn:example:params:scim:schemas:extension:User/groupId

##
# Cache configuration - use local directory for testing
##

[suffix]
prefix = ""
suffix = ""
37 changes: 34 additions & 3 deletions nss_cache/sources/httpsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ def FromHttpToTimestamp(self, http_ts_string):
"""
t = time.strptime(http_ts_string, "%a, %d %b %Y %H:%M:%S GMT")
return int(calendar.timegm(t))

def GetUpdates(self, source, url, since):
"""Get updates from a source.
def FetchUrlData(self, source, url, since=None):
"""Get HTTP response from a url.

Args:
source: A data source
Expand Down Expand Up @@ -305,6 +305,18 @@ def GetUpdates(self, source, url, since):
# Wrap in a stringIO so that it can be looped on by newlines in the parser
response = StringIO(body_bytes.decode("utf-8"))

return response, http_ts_string

def ParseUrlResponse(self, response, http_ts_string):
"""Parse the response from the HTTP request.

Args:
response: file-like object containing the data to parse
http_ts_string: HTTP timestamp string

Returns:
A tuple containing the map of updates and a maximum timestamp
"""
data_map = self.GetMap(cache_info=response)
if http_ts_string:
http_ts = self.FromHttpToTimestamp(http_ts_string)
Expand All @@ -313,6 +325,25 @@ def GetUpdates(self, source, url, since):

return data_map

def GetUpdates(self, source, url, since):
"""Get updates from a source.

Args:
source: A data source
url: url to the data we want
since: a timestamp representing the last change (None to force-get)

Returns:
A tuple containing the map of updates and a maximum timestamp

Raises:
ValueError: an object in the source map is malformed
ConfigurationError:
"""
response, http_ts_string = self.FetchUrlData(source, url, since)

return self.ParseUrlResponse(response, http_ts_string)

def GetParser(self):
"""Return the appropriate parser.

Expand Down
5 changes: 3 additions & 2 deletions nss_cache/sources/ldapsource.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ldap
import ldap.sasl
import re
import os
from binascii import b2a_hex
from packaging import version
from urllib.parse import quote
Expand Down Expand Up @@ -207,7 +208,7 @@ def _SetDefaults(self, configuration):
if "bind_dn" not in configuration:
configuration["bind_dn"] = self.BIND_DN
if "bind_password" not in configuration:
configuration["bind_password"] = self.BIND_PASSWORD
configuration["bind_password"] = os.environ.get('NSSCACHE_LDAP_BIND_PASSWORD', self.BIND_PASSWORD)
if "retry_delay" not in configuration:
configuration["retry_delay"] = self.RETRY_DELAY
if "retry_max" not in configuration:
Expand Down Expand Up @@ -842,7 +843,7 @@ def Transform(self, obj):
elif "loginShell" in obj:
pw.shell = obj["loginShell"][0]
else:
pw.shell = ""
pw.shell = self.conf.get("default_shell", "")

if self.conf.get("ad"):
# use the user's RID for uid and gid to have
Expand Down
Loading