Metadata-Version: 2.1
Name: distrolock
Version: 0.9.0
Summary: Serverless distributable authentication.
Author: ColonelParrot
License: MIT License
        
        Copyright (c) 2024 ColonelParrot
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/ColonelParrot/distrolock
Keywords: authentication,distributable,serverless
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pillow>=10.2.0
Requires-Dist: requests>=2.31.0

<p align="center">
    <img src="resources/logo-github.png" />
</p>
<h3 align="center">Serverless distributable authentication</h3>
<p align="center">Add authentication security to your distributables without a server.</p>

**Features:**

- 🔒 authenticate users for distributables with _any_ static site generator (e.g., Github Pages) - no custom server needed!
- ❌ revoke/terminate distributables remotely and in <ins>real time</ins>

**When is this needed?**

If you are sharing distributables and don't want unauthorized users to use it, or if you want the ability to revoke access to your distributable. 

## How it works

![](resources/diagram.png)

**distrolock** authenticates by sending a GET request (not POST) to **retrieve** the security policy.

Once the security policy has been retrieved, **the authentication happens client side.** On paper this is insecure,
but once compiled into an `exe` and obfuscated with tools like `pyarmor` it requires strong technical knowledge to bypass<sup>1</sup>.

The security policy looks like this:

```json
{
  "product-1": {
    "version-1": "VOID",
    "version-2": "3b0e98ef7923166602d7a9f327782eea090454960cf8bfe1af3b9c8620cd5680"
  },
  "product-2": {
    "version-1": ["ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb", "3e23e8160039594a33894f6564e1b1348bbd7a0088d42c4acb73eeaed59c009d"]
  }
}
```

> [!TIP]
> We recommend you host your security policy on online SSG's like Github Pages, where it will automatically rebuild when the policy is changed.

## Gallery

| Main Screen                   | Network Error                    | Terminated Script             |
|-------------------------------|----------------------------------|-------------------------------|
| ![](resources/demos/main.png) | ![](resources/demos/network.png) | ![](resources/demos/void.png) |

_Note_: the images can be customized!

## Tutorial

Prepend a few lines of code and you're good to go!

```python
def transformer(password):
    return sha256(password.encode()).hexdigest()


lock = DistroLock({
    "productName": "product",
    "version": "v1.0.0",
    "securityPolicyURL": "https://colonelparrot.github.io/distrolock/policy-example.json",
}, transformer)
lock.authorize() # present challenge (correct answer [asdf123])
lock.startPeriodicScan() # check for security policy changes for real-time termination

# ... your code
```

For more in-depth documentation, please visit the [wiki](https://github.com/ColonelParrot/distrolock/wiki).

### Remarks
<sup>1</sup> this tool is designed to be a solution that works out-of-the-box. It can stop _most_ people,
even some tech-savvy individuals.
