moved base64encode to common.utils

This commit is contained in:
sirferl 2020-11-24 12:29:25 +01:00
parent eedd2e91ee
commit 0f3357ab46
3 changed files with 7 additions and 15 deletions

View File

@ -10,6 +10,7 @@ import random
import re import re
import string import string
import pem import pem
import base64
import sqlalchemy import sqlalchemy
from cryptography import x509 from cryptography import x509
@ -33,6 +34,10 @@ paginated_parser.add_argument("sortBy", type=str, dest="sort_by", location="args
paginated_parser.add_argument("filter", type=str, location="args") paginated_parser.add_argument("filter", type=str, location="args")
paginated_parser.add_argument("owner", type=str, location="args") paginated_parser.add_argument("owner", type=str, location="args")
def base64encode(string):
# Performs Base64 encoding of string to string using the base64.b64encode() function
# which encodes bytes to bytes.
return base64.b64encode(string.encode()).decode()
def get_psuedo_random_string(): def get_psuedo_random_string():
""" """

View File

@ -12,20 +12,13 @@
from flask import current_app from flask import current_app
from lemur.common.defaults import common_name, bitstrength from lemur.common.defaults import common_name, bitstrength
from lemur.common.utils import parse_certificate, parse_private_key from lemur.common.utils import parse_certificate, parse_private_key, base64encode
from lemur.plugins.bases import DestinationPlugin from lemur.plugins.bases import DestinationPlugin
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
import requests import requests
import json import json
import sys import sys
import base64
def base64encode(string):
# Performs Base64 encoding of string to string using the base64.b64encode() function
# which encodes bytes to bytes.
return base64.b64encode(string.encode()).decode()
def handle_response(my_response): def handle_response(my_response):

View File

@ -18,7 +18,7 @@ import requests
from flask import current_app from flask import current_app
from lemur.common.defaults import common_name from lemur.common.defaults import common_name
from lemur.common.utils import parse_certificate from lemur.common.utils import parse_certificate, base64encode
from lemur.plugins.bases import DestinationPlugin from lemur.plugins.bases import DestinationPlugin
DEFAULT_API_VERSION = "v1" DEFAULT_API_VERSION = "v1"
@ -73,12 +73,6 @@ def _resolve_uri(k8s_base_uri, namespace, kind, name=None, api_ver=DEFAULT_API_V
) )
# Performs Base64 encoding of string to string using the base64.b64encode() function
# which encodes bytes to bytes.
def base64encode(string):
return base64.b64encode(string.encode()).decode()
def build_secret(secret_format, secret_name, body, private_key, cert_chain): def build_secret(secret_format, secret_name, body, private_key, cert_chain):
secret = { secret = {
"apiVersion": "v1", "apiVersion": "v1",