Skip to content

Commit

Permalink
feat: add helper to create persistence entry from LDIF file (#1262)
Browse files Browse the repository at this point in the history
* feat: add helper to create persistence entry from LDIF file

Helper methods are added into jans-pycloudlib directly to promote code
reuse for internal/external images (i.e. gluufederation/casa)
that need to create entry from LDIF file.

* test: remove duplicated lines

* test: remove duplicated lines builtins.open

* test: fix security hotspot

* test: change keyword for encoded string

* chore(jans-pycloudlib): updated build (#1263)

Signed-off-by: mo-auto <54212639+mo-auto@users.noreply.github.com>

* fix: remove ldif lib

Co-authored-by: mo-auto <54212639+mo-auto@users.noreply.github.com>
Co-authored-by: Mohammad Abudayyeh <47318409+moabu@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 27, 2022
1 parent 9a0150b commit f2e653e
Show file tree
Hide file tree
Showing 29 changed files with 1,080 additions and 1,005 deletions.
2 changes: 1 addition & 1 deletion docker-jans-auth-server/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
13 changes: 4 additions & 9 deletions docker-jans-auth-server/scripts/keystore_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
import os

from jans.pycloudlib.persistence.couchbase import CouchbaseClient
from jans.pycloudlib.persistence.couchbase import get_couchbase_user
from jans.pycloudlib.persistence.couchbase import get_couchbase_password
from jans.pycloudlib.persistence.ldap import LdapClient
from jans.pycloudlib.persistence.sql import SQLClient
from jans.pycloudlib.persistence.sql import SqlClient
from jans.pycloudlib.persistence.spanner import SpannerClient


Expand Down Expand Up @@ -50,10 +48,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic):

class CouchbasePersistence(BasePersistence):
def __init__(self, manager):
host = os.environ.get("CN_COUCHBASE_URL", "localhost")
user = get_couchbase_user(manager)
password = get_couchbase_password(manager)
self.client = CouchbaseClient(host, user, password)
self.client = CouchbaseClient(manager)

def get_auth_config(self):
bucket = os.environ.get("CN_COUCHBASE_BUCKET_PREFIX", "jans")
Expand Down Expand Up @@ -90,7 +85,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic):

class SqlPersistence(BasePersistence):
def __init__(self, manager):
self.client = SQLClient()
self.client = SqlClient(manager)

def get_auth_config(self):
config = self.client.get(
Expand All @@ -115,7 +110,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic):

class SpannerPersistence(SqlPersistence):
def __init__(self, manager):
self.client = SpannerClient()
self.client = SpannerClient(manager)


_backend_classes = {
Expand Down
2 changes: 1 addition & 1 deletion docker-jans-certmanager/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
grpcio==1.41.0
click==6.7
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
13 changes: 4 additions & 9 deletions docker-jans-certmanager/scripts/auth_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
from collections import deque

from jans.pycloudlib.persistence.couchbase import CouchbaseClient
from jans.pycloudlib.persistence.couchbase import get_couchbase_user
from jans.pycloudlib.persistence.couchbase import get_couchbase_password
from jans.pycloudlib.persistence.ldap import LdapClient
from jans.pycloudlib.persistence.sql import SQLClient
from jans.pycloudlib.persistence.sql import SqlClient
from jans.pycloudlib.persistence.spanner import SpannerClient
from jans.pycloudlib.utils import encode_text
from jans.pycloudlib.utils import exec_cmd
Expand Down Expand Up @@ -110,10 +108,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic, conf_webkeys):

class CouchbasePersistence(BasePersistence):
def __init__(self, manager):
host = os.environ.get("CN_COUCHBASE_URL", "localhost")
user = get_couchbase_user(manager)
password = get_couchbase_password(manager)
self.client = CouchbaseClient(host, user, password)
self.client = CouchbaseClient(manager)

def get_auth_config(self):
bucket = os.environ.get("CN_COUCHBASE_BUCKET_PREFIX", "jans")
Expand Down Expand Up @@ -152,7 +147,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic, conf_webkeys):

class SqlPersistence(BasePersistence):
def __init__(self, manager):
self.client = SQLClient()
self.client = SqlClient(manager)

def get_auth_config(self):
config = self.client.get(
Expand All @@ -177,7 +172,7 @@ def modify_auth_config(self, id_, rev, conf_dynamic, conf_webkeys):

class SpannerPersistence(SqlPersistence):
def __init__(self, manager):
self.client = SpannerClient()
self.client = SpannerClient(manager)


_backend_classes = {
Expand Down
2 changes: 1 addition & 1 deletion docker-jans-client-api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
grpcio==1.41.0
ruamel.yaml==0.16.10
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-config-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
13 changes: 4 additions & 9 deletions docker-jans-config-api/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from urllib.parse import urlparse

from jans.pycloudlib import get_manager
from jans.pycloudlib.persistence.couchbase import get_couchbase_user
from jans.pycloudlib.persistence.couchbase import get_couchbase_password
from jans.pycloudlib.persistence.couchbase import CouchbaseClient
from jans.pycloudlib.persistence.sql import SQLClient
from jans.pycloudlib.persistence.sql import SqlClient
from jans.pycloudlib.persistence.ldap import LdapClient
from jans.pycloudlib.persistence.spanner import SpannerClient

Expand All @@ -27,10 +25,7 @@ def get_auth_config(self):

class CouchbasePersistence:
def __init__(self, manager):
host = os.environ.get("CN_COUCHBASE_URL", "localhost")
user = get_couchbase_user(manager)
password = get_couchbase_password(manager)
self.client = CouchbaseClient(host, user, password)
self.client = CouchbaseClient(manager)

def get_auth_config(self):
bucket = os.environ.get("CN_COUCHBASE_BUCKET_PREFIX", "jans")
Expand All @@ -48,7 +43,7 @@ def get_auth_config(self):

class SqlPersistence:
def __init__(self, manager):
self.client = SQLClient()
self.client = SqlClient(manager)

def get_auth_config(self):
config = self.client.get(
Expand All @@ -61,7 +56,7 @@ def get_auth_config(self):

class SpannerPersistence(SqlPersistence):
def __init__(self, manager):
self.client = SpannerClient()
self.client = SpannerClient(manager)


def transform_url(url):
Expand Down
2 changes: 1 addition & 1 deletion docker-jans-configurator/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ click==6.7
marshmallow==3.10.0
fqdn==1.4.0
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
2 changes: 1 addition & 1 deletion docker-jans-fido2/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
libcst<0.4
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
3 changes: 1 addition & 2 deletions docker-jans-persistence-loader/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# pinned to py3-grpcio version to avoid failure on native extension build
grpcio==1.41.0
ldif==4.1.1
libcst<0.4
ruamel.yaml==0.16.10
git+https://github.com/JanssenProject/jans@abc89dc6fadae5627a68a97ab4f4f5ceb56af809#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
git+https://github.com/JanssenProject/jans@12cf1be739f320483365e0e50b37b894b5364a6f#egg=jans-pycloudlib&subdirectory=jans-pycloudlib
Loading

0 comments on commit f2e653e

Please sign in to comment.