Commit d3ab38d3 authored by Grant, Josh's avatar Grant, Josh
Browse files

update the documentation; include documentation dependency in Pipfile

parent faea14fa
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ pylint = "*"
tox = "*"
twine = "*"
moto = {extras = ["all"], version = "*"}
pydoc-markdown = "*"

[scripts]
lint = "tox -e lint"
+1048 −877

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
<a name="common.__init__"></a>
<a id="common.__init__"></a>

# common.\_\_init\_\_

Common package to assist in rapid package development.

docs/auth.md

0 → 100644
+48 −0
Original line number Diff line number Diff line
<a id="common.auth"></a>

# common.auth

Provide authentication methods.

<a id="common.auth.authenticate_ldap_user"></a>

#### authenticate\_ldap\_user

```python
def authenticate_ldap_user(uid, password)
```

Authenticates a user against an LDAP server using their user ID and password.

This function retrieves the necessary LDAP configuration from environment variables,
establishes a connection to the LDAP server, and attempts to bind with the provided
credentials. If the binding is successful, it searches for the user's entry and returns it.

**Arguments**:

  - uid (str): The user ID of the LDAP account to authenticate.
  - password (str): The password for the LDAP account.
  

**Returns**:

  - ldap3.Entry: The LDAP entry of the authenticated user if successful.
  - None: If the authentication fails (e.g., incorrect credentials or issues with server connection).
  
  Environment Variables:
  - LDAP_SERVER: URL of the LDAP server. Default is "ldaps://ldapx.ornl.gov".
  - LDAP_ROOT_DN: The root distinguished name (DN) for LDAP queries. Default is "dc=xcams,dc=ornl,dc=gov".
  - LDAP_USER_DN: Template for constructing the user's DN. Default is "uid={uid},ou=Users".
  - LDAP_USER_SEARCH_FILTER: LDAP search filter to find the user. Default is "(uid={uid})".
  

**Example**:

  To authenticate a user with ID 'jdoe' and password 'securepassword', you can call:
  authenticate_ldap_user('jdoe', 'securepassword')
  

**Raises**:

  - ldap3.core.exceptions.LDAPException: If there is an issue connecting to the LDAP server or during the search.

docs/crud_table.md

0 → 100644
+139 −0
Original line number Diff line number Diff line
<a id="common.crud_table"></a>

# common.crud\_table

** AUTHOR **
Alec Hamaker

** WRITTEN **
April 4, 2020

** PURPOSE **
The purpose of this file is to create an abstract base class that provides
basic crud operations to database tables.

<a id="common.crud_table.convert_to_where"></a>

#### convert\_to\_where

```python
def convert_to_where(dictionary)
```

convert's the dictionary to an SQL where clause

**Arguments**:

- `dictionary`: key value mapping for where clause

<a id="common.crud_table.convert_to_update"></a>

#### convert\_to\_update

```python
def convert_to_update(dictionary)
```

convert's the dictionary to an SQL update clause

**Arguments**:

- `dictionary`: 

<a id="common.crud_table.CRUDTable"></a>

## CRUDTable Objects

```python
class CRUDTable(ABC)
```

Defines a database table with standard CRUD operations

<a id="common.crud_table.CRUDTable.__init__"></a>

#### \_\_init\_\_

```python
def __init__(columns, schema, db, table_name=None)
```

__init__.

**Arguments**:

- `columns`: dictionary like {'id': int, 'email': str}

<a id="common.crud_table.CRUDTable.create"></a>

#### create

```python
def create(**kwargs)
```

creates an entry in the table

**Arguments**:

- `kwargs`: column_name=value for every column

<a id="common.crud_table.CRUDTable.read"></a>

#### read

```python
def read(columns: list = None, json: bool = False, **kwargs)
```

Reads an entry from the table

**Arguments**:

- `columns` (`list`): columns to select
- `json` (`bool`): if output should be in json format
- `kwargs`: where clause keyword arguments

<a id="common.crud_table.CRUDTable.update"></a>

#### update

```python
def update(where: dict, **kwargs)
```

update.

**Arguments**:

- `where` (`dict`): dictionary to define the where clause
- `kwargs`: keys and values to update in the database

<a id="common.crud_table.CRUDTable.delete"></a>

#### delete

```python
def delete(**kwargs)
```

delete.

**Arguments**:

- `kwargs`: where clause to delete on

<a id="common.crud_table.CRUDTable.fetch_json"></a>

#### fetch\_json

```python
def fetch_json(cursor)
```

fetches json/diction data from the database

**Arguments**:

- `cursor`: database cursor to fetch from
Loading