Skip to main content

Library to work with htpasswd user (basic authorization) and group files.

Project description

# htpasswd

## Description htpasswd is a library for working with htpasswd user (only basic authorization) and group files.

## Dependencies - Python 2.6 or 2.7 - [orderedmultidict](http://pypi.python.org/pypi/orderedmultidict/0.7) >= 0.7

## Sample usage

import htpasswd

with htpasswd.Basic(“/path/to/user.db”) as userdb:
try:

userdb.add_user(“bob”, “password”)

except htpasswd.basic.UserExists, e:

print e

try:

userdb.change_password(“alice”, “newpassword”)

except htpasswd.basic.UserNotExists, e:

print e

with htpasswd.Group(“/path/to/group.db”) as groupdb:
try:

groupdb.add_user_to_group(“bob”, “admins”)

except htpasswd.group.UserAlreadyInAGroup, e:

print e

try:

groupdb.delete_user_from_group(“alice”, “managers”)

except htpasswd.group.UserNotInAGroup, e:

print e

## Provided methods

### Basic - show_users() - is_user_exists(user) - add_user(user, password) - delete_user(user) - change_password(user, password) - _crypt_password(password)

### Group - show_groups() - is_group_exists(group) - is_user_in_a_group(user, group) - add_user_to_group(user, group) - delete_user_from_group(user, group)

## Exceptions

### HtException

That’s a general exception from which others are inherited.

### UserExists Raised by add_user if user already exists.

### UserNotExists Raised by delete_user and change_password if there is no such user.

### GroupNotExists Raised by delete_user_from_group if there is no such group.

### UserAlreadyInAGroup Raised by add_user_to_group if user is already in a group.

### UserNotInAGroup Raised by delete_user_from_group if user isn’t in a group.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htpasswd-1.0.tar.gz (2.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page