Skip to content

Commit

Permalink
Move code to pinecrypt.client Python package
Browse files Browse the repository at this point in the history
  • Loading branch information
laurivosandi committed Apr 11, 2021
1 parent 4eb2c17 commit 447aa70
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 7 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:20.04 as build
ENV PYTHONUNBUFFERED=1
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive

# Make apt faster
RUN echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup
RUN echo "Dpkg::Use-Pty=0;" > /etc/apt/apt.conf.d/99quieter

RUN apt-get update -qq
RUN apt-get install -y -qq \
python3-pip

COPY pinecrypt/client/. /src/pinecrypt/client
COPY setup.py /src/
COPY README.md /src/
COPY misc/ /src/misc/
WORKDIR /src
RUN pip3 install .

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Background

Certidude is the VPN connectivity client for Pinecrypt Gateway
6 changes: 6 additions & 0 deletions misc/certidude
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

from pinecrypt.client.cli import entry_point

if __name__ == "__main__":
entry_point()
Empty file added pinecrypt/client/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions cli.py → pinecrypt/client/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# coding: utf-8

import click
import const
import hashlib
import logging
import os
Expand All @@ -13,7 +12,6 @@
import subprocess
import sys
import requests
from jinja2 import Environment, PackageLoader
from ipsecparse import loads
from asn1crypto import pem, x509
from asn1crypto.csr import CertificationRequest
Expand All @@ -22,6 +20,7 @@
from configparser import ConfigParser, NoOptionError
from datetime import datetime, timedelta
from oscrypto import asymmetric
from pinecrypt.client import const

class ConfigTreeParser(ConfigParser):
def __init__(self, path, *args, **kwargs):
Expand All @@ -43,6 +42,7 @@ def __init__(self, path, *args, **kwargs):
@click.argument("authority")
def certidude_provision(authority):
client_config = ConfigParser()
os.makedirs(os.path.dirname(const.CLIENT_CONFIG_PATH))
if os.path.exists(const.CLIENT_CONFIG_PATH):
client_config.read_file(open(const.CLIENT_CONFIG_PATH))
if client_config.has_section(authority):
Expand All @@ -60,7 +60,7 @@ def certidude_provision(authority):
with open(const.CLIENT_CONFIG_PATH + ".part", 'w') as fh:
client_config.write(fh)
os.rename(const.CLIENT_CONFIG_PATH + ".part", const.CLIENT_CONFIG_PATH)

os.system("certidude enroll")

@click.command("enroll", help="Run processes for requesting certificates and configuring services")
@click.option("-k", "--kerberos", default=False, is_flag=True, help="Offer system keytab for auth")
Expand Down
File renamed without changes.
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

43 changes: 43 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
# coding: utf-8
import os
from setuptools import setup

setup(
name = "certidude",
version = "0.2.1",
author = u"Pinecrypt Labs",
author_email = "[email protected]",
description = "Certidude provisions VPN connections to Pinecrypt Gateway",
license = "MIT",
keywords = "falcon http jinja2 x509 pkcs11 webcrypto kerberos ldap",
url = "https://git.k-space.ee/pinecrypt/certidude",
packages=[
"pinecrypt.client",
],
long_description=open("README.md").read(),
install_requires=[
"asn1crypto",
"certbuilder",
"click",
"csrbuilder",
"ipsecparse",
"requests",
],
scripts=[
"misc/certidude"
],
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"License :: Freely Distributable",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
],
)

0 comments on commit 447aa70

Please sign in to comment.