Skip to main content

knw-license

IP 기반으로 Python 앱의 실행 환경을 제한하는 라이브러리입니다.

설치

pip install knw-license

사용법

함수형

import knw_license

# 공인 IP 검사 (기본)
knw_license.check()

# 내부 IP 검사
knw_license.check(mode="local")

# 공인 + 내부 중 하나라도 허용 목록에 있으면 통과
knw_license.check(mode="both")

데코레이터형

from knw_license import guard

@guard
def main():
    print("허용된 환경에서 실행 중")

@guard(mode="both")
def main():
    print("허용된 환경에서 실행 중")

예외 처리

from knw_license.exceptions import AccessDeniedError, IPResolutionError

try:
    knw_license.check()
except AccessDeniedError as e:
    print(f"차단된 IP: {e.ip}")
    print(f"검사 모드: {e.mode}")
except IPResolutionError as e:
    print(f"IP 조회 실패: {e}")

IP 목록 관리

knw_license/_allowlist.py 의 ALLOWED_CIDRS 리스트를 수정합니다.

ALLOWED_CIDRS: list[str] = [
    "203.0.113.5/32",   # 단일 공인 IP
    "192.168.1.0/24",   # 사무실 내부망
    "10.0.0.0/8",       # VPN 대역
]

변경 후 버전을 올려 재배포합니다.

# pyproject.toml 버전 수정 후
python -m build
twine upload dist/*

Metadata

Release files for knw-license 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for knw-license 0.1.1
File Size Uploaded Provenance Actions
knw_license-0.1.1.tar.gz 5.5 kB Without provenance Details for knw_license-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for knw-license 0.1.1
File Interpreter ABI Platform Actions
knw_license-0.1.1-py3-none-any.whl Python 3 none any Details for knw_license-0.1.1-py3-none-any.whl

Total release size: 12.6 kB

Release files / knw_license-0.1.1.tar.gz

Download URL knw_license-0.1.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f72303c95a77063805c26bbf41c0cb29f0ec44656c750f1cf9fcb0406a4c6a22
BLAKE2b-256 checksum
How to use checksums
f2c62a918042d18090d9cfbda13113caa2ffa5d53acfc9bb059e85724fdda7a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / knw_license-0.1.1-py3-none-any.whl

Download URL knw_license-0.1.1-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9f8c6b20ed6fef157f9b094dacc6cf2013c2cd5aea5e827322d4575dabb04d9
BLAKE2b-256 checksum
How to use checksums
53c5428275c4363cc98f19802021035cf33cf106f2dc349d2e40c7d7234dc5a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for knw-license 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page