Skip to content

Commit

Permalink
Rename to sspilib
Browse files Browse the repository at this point in the history
Another rename to sspilib as the previous name was too close to a racial
slur that I was no aware about.
  • Loading branch information
jborean93 committed Oct 3, 2023
1 parent ac05073 commit 3732544
Show file tree
Hide file tree
Showing 49 changed files with 85 additions and 85 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ jobs:
- name: extract sdist
shell: bash
run: |
tar xf sspic-*.tar.gz
mv sspic-*/* .
rm -r sspic-*/
rm sspic-*.tar.gz
tar xf sspilib-*.tar.gz
mv sspilib-*/* .
rm -r sspilib-*/
rm sspilib-*.tar.gz
- name: build wheel
uses: pypa/cibuildwheel@v2.16.0
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
- 3.9
- '3.10'
- '3.11'
- '3.12.0-rc.3'
- '3.12'
python-arch:
- x86
- x64
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## 0.1.0 - 2024-09-29
## 0.1.0 - 2024-10-04

First official release of the `sspic` Python module.
First official release of the `sspilib` Python module.
This includes both the high and low level API used for interacting with SSPI.
As well as Windows support, there is experimental Linux and macOS support using [sspi-rs](https://github.com/Devolutions/sspi-rs) as the SSPI implementation that ships with the wheels on those platforms.
8 changes: 4 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ exclude .coverage
exclude .gitignore
exclude .pre-commit-config.yaml
recursive-include build_helpers *
include src/sspic/raw/*.h
include src/sspic/raw/*.pyx
include src/sspic/raw/*.pxd
exclude src/sspic/raw/*.c
include src/sspilib/raw/*.h
include src/sspilib/raw/*.pyx
include src/sspilib/raw/*.pxd
exclude src/sspilib/raw/*.c
recursive-include stubs *
recursive-include tests *
recursive-exclude tests *.pyc
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Python SSPI Library

[![Test workflow](https://github.com/jborean93/pysspi/actions/workflows/ci.yml/badge.svg)](https://github.com/jborean93/pysspi/actions/workflows/ci.yml)
[![PyPI version](https://badge.fury.io/py/sspic.svg)](https://badge.fury.io/py/sspic)
[![PyPI version](https://badge.fury.io/py/sspilib.svg)](https://badge.fury.io/py/sspilib)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jborean93/pysspi/blob/main/LICENSE)

This library provides Python functions that wraps the Windows SSPI API.
It is designed to be both a high and low level interface that other libraries can easily leverage to use with SSPI integration.
The high level interface is under the `sspic` namespace whereas the low-level interface is under the `sspic.raw` interface.
The high level interface is under the `sspilib` namespace whereas the low-level interface is under the `sspilib.raw` interface.

## Requirements

Expand All @@ -19,24 +19,24 @@ More requires are needed to compile the code from scratch but this library is sh
Simply run:

```bash
pip install sspic
pip install sspilib
```

To install from source run the following:

```bash
git clone https://github.com/jborean93/pysspic.git
git clone https://github.com/jborean93/sspilib.git
python -m pip install build
python -m build
pip install dist/sspic-*.whl
pip install dist/sspilib-*.whl
```

## Development

To run the tests or make changes to this repo run the following:

```bash
git clone https://github.com/jborean93/pysspic.git
git clone https://github.com/jborean93/sspilib.git
pip install -r requirements-dev.txt
pre-commit install

Expand Down Expand Up @@ -65,12 +65,12 @@ export LIBRARY_PATH="${PWD}/target/release"
## Structure

This library is merely a wrapper around the SSPI APIs.
The high level API under `sspic` exposes an easier to use Python API for SSPI.
The functions under the `sspic.raw` namespace expose the various SSPI functions under a more Pythonic snake_case format.
For example the [AcquireCredentialsHandle](https://learn.microsoft.com/en-us/windows/win32/secauthn/acquirecredentialshandle--general) function is exposed as `sspic.raw.acquire_credentials_handle`.
The high level API under `sspilib` exposes an easier to use Python API for SSPI.
The functions under the `sspilib.raw` namespace expose the various SSPI functions under a more Pythonic snake_case format.
For example the [AcquireCredentialsHandle](https://learn.microsoft.com/en-us/windows/win32/secauthn/acquirecredentialshandle--general) function is exposed as `sspilib.raw.acquire_credentials_handle`.

Errors are raised as a `WindowsError` which contains the error message as formatted by Windows and the error code.
For non-Windows hosts there is a compatible `sspic.WindowsError` class that is structured like the Windows only `WindowsError` builtin.
For non-Windows hosts there is a compatible `sspilib.WindowsError` class that is structured like the Windows only `WindowsError` builtin.
Some of the objects and constants are exposed as Python classes/dataclasses/enums for ease of use.
Please read through the docstring of the function that will be used to learn more about how to use them.

Expand All @@ -79,14 +79,14 @@ Please read through the docstring of the function that will be used to learn mor
Here is a basic example of how to use this library for client authentication:

```python
import sspic
import sspilib

cred = sspic.UserCredential(
cred = sspilib.UserCredential(
"username@DOMAIN.COM",
"password",
)

ctx = sspic.ClientSecurityContext(
ctx = sspilib.ClientSecurityContext(
"host/server.domain.com",
credential=cred,
)
Expand Down
4 changes: 2 additions & 2 deletions build_helpers/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ lib::setup::python_requirements() {
echo "::group::Installing Python Requirements"
fi

echo "Installing sspic"
echo "Installing sspilib"
if [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ]; then
DIST_LINK_PATH="$( echo "${PWD}/dist" | sed -e 's/^\///' -e 's/\//\\/g' -e 's/^./\0:/' )"
else
Expand All @@ -28,7 +28,7 @@ lib::setup::python_requirements() {
python -m pip install build
SSPI_VERSION="$( grep -m 1 version pyproject.toml | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3 )"

python -m pip install sspic=="${SSPI_VERSION}" \
python -m pip install sspilib=="${SSPI_VERSION}" \
--find-links "file:///${DIST_LINK_PATH}" \
--verbose

Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ requires = [
build-backend = "setuptools.build_meta"

[project]
name = "sspic"
version = "0.1.1"
name = "sspilib"
version = "0.1.0"
description = "SSPI API bindings for Python"
readme = "README.md"
requires-python = ">=3.8"
Expand Down Expand Up @@ -37,11 +37,11 @@ include-package-data = true
where = ["src"]

[tool.setuptools.package-data]
sspic = ["py.typed"]
"sspic.raw" = ["*.pyi"]
sspilib = ["py.typed"]
"sspilib.raw" = ["*.pyi"]

[tool.setuptools.exclude-package-data]
"sspic.raw" = ["*.h", "*.pxd", "*.pyx"]
"sspilib.raw" = ["*.h", "*.pxd", "*.pyx"]

[tool.black]
line-length = 120
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def make_extension(
canary = e[2]

ext = make_extension(
f"sspic.raw._{name}",
f"sspilib.raw._{name}",
module=sspi,
canary=canary,
extra_compile_args=extra_compile_args,
Expand Down
4 changes: 2 additions & 2 deletions src/sspic/__init__.py → src/sspilib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from __future__ import annotations

import sspic.raw as raw
from sspic.raw import AscReq, AscRet, IscReq, IscRet, SecChannelBindings, WindowsError
import sspilib.raw as raw
from sspilib.raw import AscReq, AscRet, IscReq, IscRet, SecChannelBindings, WindowsError

from ._credential import UserCredential
from ._sec_context import (
Expand Down
4 changes: 2 additions & 2 deletions src/sspic/_credential.py → src/sspilib/_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import datetime
import typing as t

import sspic.raw as raw
import sspilib.raw as raw

from ._filetime import filetime_to_datetime

Expand All @@ -31,7 +31,7 @@ class UserCredential(raw.CredHandle):
UserCredential(protocol="Negotiate", protocol_list["!ntlm"])
This class is designed to be a high level overlay on top of the
:class:`sspic.raw.CredHandle` class. It can be used as a credential for both
:class:`sspilib.raw.CredHandle` class. It can be used as a credential for both
the high level API as well as te low level API if more complex scenarios
are needed.
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions src/sspic/_sec_context.py → src/sspilib/_sec_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import datetime
import typing as t

import sspic.raw as raw
import sspilib.raw as raw

from ._filetime import filetime_to_datetime

Expand Down Expand Up @@ -128,7 +128,7 @@ def wrap(
stage to honour the encryption request.
If a more complex set of buffers is needed to wrap the data, use the
:meth:`sspic.raw.encrypt_message` function with this context.
:meth:`sspilib.raw.encrypt_message` function with this context.
Args:
data: The data to wrap.
Expand Down Expand Up @@ -175,7 +175,7 @@ def unwrap(
then provide a byte string or readonly memoryview.
If a more complex set of buffers is needed to unwrap the data, use the
:meth:`sspic.raw.decrypt_message` function with this context.
:meth:`sspilib.raw.decrypt_message` function with this context.
Args:
data: The data to unwrap.
Expand Down Expand Up @@ -218,7 +218,7 @@ def sign(
then provide a byte string or readonly memoryview.
If a more complex set of buffers is needed to sign the data, use the
:meth:`sspic.raw.make_signature` function with this context.
:meth:`sspilib.raw.make_signature` function with this context.
Args:
data: The data to sign.
Expand Down Expand Up @@ -262,7 +262,7 @@ def verify(
then provide a byte string or readonly memoryview.
If a more complex set of buffers is needed to unwrap the data, use the
:meth:`sspic.raw.verify_signature` function with this context.
:meth:`sspilib.raw.verify_signature` function with this context.
Args:
data: The data to verify.
Expand Down Expand Up @@ -315,8 +315,8 @@ class ClientSecurityContext(SecurityContext):
This represents an SSPI security context that can be used for client side
authentication. This class is designed to be a high level overlay on top of
the :class:`sspic.raw.CtxtHandle` class. it can be used directly with
any low level API in the ``sspic.raw`` namespace that requires a context
the :class:`sspilib.raw.CtxtHandle` class. it can be used directly with
any low level API in the ``sspilib.raw`` namespace that requires a context
handle instance in case the low level interface doesn't expose the methods
needed.
Expand Down Expand Up @@ -399,8 +399,8 @@ class ServerSecurityContext(SecurityContext):
This represents an SSPI security context that can be used for server side
authentication. This class is designed to be a high level overlay on top of
the :class:`sspic.raw.CtxtHandle` class. it can be used directly with
any low level API in the ``sspic.raw`` namespace that requires a context
the :class:`sspilib.raw.CtxtHandle` class. it can be used directly with
any low level API in the ``sspilib.raw`` namespace that requires a context
handle instance in case the low level interface doesn't expose the methods
needed.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _replace_cred_handle(
CredHandle src not None,
CredHandle dst not None,
) -> None:
# This is only used by sspic._credential.py to store the cred state in
# This is only used by sspilib._credential.py to store the cred state in
# itself.
dst.raw = src.raw
dst.needs_free = src.needs_free
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cdef extern from "python_sspi.h":
{
if (WinError == NULL)
{
PyObject *winerror = PyImport_ImportModule("sspic.raw._winerror");
PyObject *winerror = PyImport_ImportModule("sspilib.raw._winerror");
if (winerror == NULL)
{
PyErr_SetString(PyExc_RuntimeError, "Failed to import custom WindowsError.");
Expand Down
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@

import pytest

import sspic
import sspilib


@pytest.fixture()
def initial_contexts() -> tuple[sspic.ClientSecurityContext, sspic.ServerSecurityContext]:
def initial_contexts() -> tuple[sspilib.ClientSecurityContext, sspilib.ServerSecurityContext]:
spn = f"host/{socket.gethostname()}"

# sspi-rs only supports acceptors for NTLM at this point in time. it also
# cannot rely on implicit creds
if os.name == "nt":
c_cred = sspic.UserCredential(protocol="NTLM")
s_cred = sspic.UserCredential(usage="accept")
c_cred = sspilib.UserCredential(protocol="NTLM")
s_cred = sspilib.UserCredential(usage="accept")
else:
c_cred = sspic.UserCredential("user", "pass", protocol="NTLM")
s_cred = sspic.UserCredential("user", "pass", protocol="NTLM", usage="accept")
c_cred = sspilib.UserCredential("user", "pass", protocol="NTLM")
s_cred = sspilib.UserCredential("user", "pass", protocol="NTLM", usage="accept")

c_ctx = sspic.ClientSecurityContext(target_name=spn, credential=c_cred)
s_ctx = sspic.ServerSecurityContext(credential=s_cred)
c_ctx = sspilib.ClientSecurityContext(target_name=spn, credential=c_cred)
s_ctx = sspilib.ServerSecurityContext(credential=s_cred)

return c_ctx, s_ctx


@pytest.fixture()
def authenticated_contexts(
initial_contexts: tuple[sspic.ClientSecurityContext, sspic.ServerSecurityContext],
) -> tuple[sspic.ClientSecurityContext, sspic.ServerSecurityContext]:
initial_contexts: tuple[sspilib.ClientSecurityContext, sspilib.ServerSecurityContext],
) -> tuple[sspilib.ClientSecurityContext, sspilib.ServerSecurityContext]:
c_ctx, s_ctx = initial_contexts

s_token = None
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_context_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

import sspic.raw as sr
import sspilib.raw as sr


# https://github.com/Devolutions/sspi-rs/issues/169
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

import sspic.raw as sr
import sspilib.raw as sr


@pytest.mark.skipif(os.name != "nt", reason="sspi-rs does not support implicit creds outside Windows")
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_credential_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os

import sspic.raw as sr
import sspilib.raw as sr


def test_set_kdc_proxy_default() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest

import sspic.raw as sr
import sspilib.raw as sr


@pytest.mark.skipif(os.name != "nt", reason="sspi-rs does not support signature functions")
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_security_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

import sspic.raw as sr
import sspilib.raw as sr


def test_empty_sec_buffer_desc() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/raw/test_security_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

import sspic.raw as sr
import sspilib.raw as sr


def test_sec_exchange_alloc_memory() -> None:
Expand Down
Loading

0 comments on commit 3732544

Please sign in to comment.