Skip to content

Commit

Permalink
chore: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
devraj committed Aug 25, 2024
2 parents c83e87e + 55c8e4c commit 206e453
Show file tree
Hide file tree
Showing 65 changed files with 2,162 additions and 816 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Use an official Python runtime based on Debian 12 "bookworm" as a parent image.
FROM python:3.12-slim-bookworm

# Install system packages required by Wagtail and Django.
RUN apt-get update --yes --quiet
RUN apt-get install --yes --quiet --no-install-recommends build-essential
RUN rm -rf /var/lib/apt/lists/*

# Copy poetry files and get ready to install package
WORKDIR /opt
COPY poetry.lock poetry.lock
COPY pyproject.toml pyproject.toml

# Ask poetry to install all packages including the app
# not in virtual machine as we are in a container
# In prodduction add --no-dev to poetry installation
RUN pip3 install --upgrade pip
RUN pip3 install poetry
RUN poetry config virtualenvs.create false
RUN poetry install --no-root

# Build and install the package
COPY gallagher gallagher
# README is reference by the package
COPY README.md README.md
RUN poetry build

# Install the package
RUN pip3 install dist/*.whl

# Remove the source
RUN rm -rf gallagher
RUN rm -rf dist
RUN rm README.md

# Copy the files in the src directory which is the app package
# and the dependency matrix dedescribed by pyproject.toml
WORKDIR /opt/gallagher

# Run the CLI
ENTRYPOINT [ "gala" ]
124 changes: 121 additions & 3 deletions HARDWARE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,131 @@ A big thank you to [Gallagher Security](http://security.gallagher.com) for provi
- [Gallagher Command Centre](http://security.gallagher.com) central command centre software (hosted on an AWS EC2 instance)
- [Gallagher Mobile Connect](http://security.gallagher.com) app to unlock the door

## Writing
## Wiring

## Setup
Our T15 Multi Tech Reader is connected to the Controller 7000 Single Door. Our setup has a single reader and our wiring is as follows on the controller:

```
┌───┐
│ A │ Green and Orange
│ B │ Brown
│ - │ Black
│ + │ Red
└───┘
```

> [!NOTE]
> Since we have the one reader, the orange wire signifies it it to be the terminating reader and hence the green and orange are banded together on the A terminal.
## Command Centre Setup

> [!IMPORTANT]\
> You should either refer to the Gallagher Documentation for detailed information on configuring the Command Centre. You also require a license from Gallagher for this feature to work.
> If you are unsure, please contact your Gallagher representative as misconfiguration can lead to security vulnerabilities.
Your checklist, before you proceed to using the REST features:

- You are running Command Centre version `8.60` or higher, older versions predate the gateway so cannot support it
- The gateway enabled at the system level
- If it is, has the gateway been enabled for your specific API key

You will also require:

- MAC address of the Controller 7000 Single Door (found on the inside of the controller)
- Serial number of the T15 Multi Tech Reader (found on the back of the reader)

Hardware

Door

Reader

Controller Input

Controller Output

Alarm Zone

Access Group

### Enabling the REST API Cloud Gateway

All of the above requires you to have an understanding of the Gallagher Command Centre and how to configure it.

To check the system level gateway status:

- Open the Command Centre Configuration Client
- From the `Configure` menu, select `Services and Workstations`
- Find the `Command Centre Cloud` item and double-click it
- Switch to the `Configuration` page, it should look something like this:

![Command Centre Cloud Configuration](https://raw.githubusercontent.com/anomaly/gallagher/master/assets/gallagher-command-centre-properties.png)

To check your API key:

- Open the Command Centre Configuration Client
- From the `Configure` menu, select `Services and Workstations`
- Find the item that represents your REST Client
- Switch to the `Connections` page, it should look something like this

![Command Centre Cloud Connections](https://raw.githubusercontent.com/anomaly/gallagher/master/assets/gallagher-rest-properties.png)

> [!CAUTION]\
> All operations require the use of the API key. Never distribute your API key or store it somewhere that is not secure.
> For security it's recommended you read the API key from an environment variable.
## AWS and the Local Setup

Gallagher provides ample documentation on how to configure the Controller and a remote Control Centre instance to communicate with each other. Most of the setup complication are around NAT (and security). These are some steps I took note of which putting together our setup.

I have broke my notes into two parts:

- Initial setup based on CC and Controller communicating over the public Internet
- VPN based setup to secure the channel between the CC and Controller

### Over the public Internet

Follow the initial setup guide from your Controller 7000 Single Door documentation. The steps are as follows:

- Set DIP switch `1`, `2`, `3` to ON
- Navigate to `192.168.1.199` in your browser (depending on your local network setup you will have to vary your routing rules)
- Choose static IP as your networking configuration

These are the steps that I had to make note of on the Static IP setting while communicating over a WAN:

- Server IP is the WAN IP of the AWS EC2 instance
- Controller IP is the LAN IP of the Controller 7000 Single Door, in this instance a static IP of the AWS instance
- My Controller has the static IP of `192.168.1.180` on the local network

![Single Door 7000 Controller IP configuration](assets/wan-7000-ip.png)

Local network NAT rules:

- Open port `1072` from the outside world to the controller, this is what the CC will use to communicate with the controller
- For best practices restrict this port to be open for the AWS instance IP only

On the AWS EC2 instance (firewall settings):

- You have allow inbound requests on port `1072` (I missed this in the documentation and assume it's described further in the CC docs)

#### Configuring the Controller for WAN

Upon configuring the Controller it would come online and then quickly reset itself and become unresponsive. After a bit of debugging it occurred to me that the CC was pushing the configuration it thought the Controller should have.

To overcome this I had to configure the CC to push the same information as the initial configuration on the controller that got it online and communicating with the CC.

Network Method should be set to `Manual`:

- The IP address will be of the local network where the Controller is located and connected
- Override the Server Address to provide the `WAN` address of the Command Centre

As per the Gallagher guide override the NAT settings in this panel to provide the WAN address of the network the Controller is located in.

> [!NOTE]
> Each time the Controller needed to be reset, it would issue a new certificate. You have to locate the controller on the Command Centre, head over to `Status and Overrides` and ask it to fetch a new certificate.
![Controller configuration to work over the WAN](assets/wan-7000-cc-config.png)

## Reference videos

Official video tutorials from Gallagher Security:
Expand All @@ -30,5 +149,4 @@ Official video tutorials from Gallagher Security:
Official documentation:

- [Controller 7000 Single door](https://products.security.gallagher.com/security/global/en/products/access-control-hardware/controller-7000-single-door/p/BVC400011)

- [Controller 7000 Single door documents](https://media.gallagher.com/web/1a00857c7c9c8d7/single-door-controller-7000-qr-code/?viewType=grid)
44 changes: 4 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Gallagher Python Toolkit

> The missing toolkit for extending Gallagher Command Centre
> The missing developer toolkit for Gallagher Command Centre
[![PyPI version](https://badge.fury.io/py/gallagher.svg)](https://badge.fury.io/py/gallagher)
[![Python Version](https://img.shields.io/pypi/pyversions/gallagher)](https://pypi.org/project/gallagher/)
Expand Down Expand Up @@ -47,7 +47,7 @@ from gallagher.dto.summary import (
CardholderSummary,
)
from gallagher.cc.cardholders import (
Cardholder
Cardholder,
)

# Set the API key from the environment
Expand Down Expand Up @@ -327,45 +327,9 @@ In this example the `AppGroupRef` has a `name` attribute which is not present in

> Please see the schema section for naming conventions for `schema` classes
## Configuring the Command Centre

All of the above requires you to have an understanding of the Gallagher Command Centre and how to configure it.

> [!IMPORTANT]\
> You should either refer to the Gallagher Documentation for detailed information on configuring the Command Centre. You also require a license from Gallagher for this feature to work.
> If you are unsure, please contact your Gallagher representative as misconfiguration can lead to security vulnerabilities.
Your checklist, before you proceed to using the REST features:

- You are running Command Centre version `8.60` or higher, older versions predate the gateway so cannot support it
- The gateway enabled at the system level
- If it is, has the gateway been enabled for your specific API key

To check the system level gateway status:

- Open the Command Centre Configuration Client
- From the `Configure` menu, select `Services and Workstations`
- Find the `Command Centre Cloud` item and double-click it
- Switch to the `Configuration` page, it should look something like this:

![Command Centre Cloud Configuration](https://raw.githubusercontent.com/anomaly/gallagher/master/assets/gallagher-command-centre-properties.png)

To check your API key:

- Open the Command Centre Configuration Client
- From the `Configure` menu, select `Services and Workstations`
- Find the item that represents your REST Client
- Switch to the `Connections` page, it should look something like this

![Command Centre Cloud Connections](https://raw.githubusercontent.com/anomaly/gallagher/master/assets/gallagher-rest-properties.png)

> [!CAUTION]\
> All operations require the use of the API key. Never distribute your API key or store it somewhere that is not secure.
> For security it's recommended you read the API key from an environment variable.
## Resources

The following are resources that were discoverd during the design and development of this library.
The following are resources that were discoverd during the design and development of these tools. Not all of them are in use by the toolkit, they were discovered as the library evolved.

### Python Libraries

Expand All @@ -388,4 +352,4 @@ Distributed under the MIT License except Artwork and Branding assets.

- [Matthew Skiles](https://matthewskiles.com) for the beautiful logo for the project.
- [Orion Edwards](https://github.com/borland) for all his support on getting @devraj started with the Gallagher API.
- [Mick Lambert](https://www.linkedin.com/in/michael-lambert-au/), [Tim Harris](https://www.linkedin.com/in/timharris01/), [Andrew Donkin](https://github.com/andrewdonkin) from the Gallagher team for all their support.
- [Mick Lambert](https://www.linkedin.com/in/michael-lambert-au/), [Tim Harris](https://www.linkedin.com/in/timharris01/), [Andrew Donkin](https://github.com/andrewdonkin), [Mike Margrain](https://www.linkedin.com/in/mike-margrain-b914381a/), [Nathan Matera](https://www.linkedin.com/in/nathan-matera-0a30b6240/) from the Gallagher team for all their support.
18 changes: 16 additions & 2 deletions TUI.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@

> The TUI is developed using the superpowers given to Python developers by [Textual](https://textual.textualize.io)
Cardholder management
The aim of this TUI is to provide a power console for the Gallagher Ecosystem, which is complimentary to the Gallagher Command Centre and makes use of the Gallagher REST API.

Think of it as the Terminal GUI equivalent of what the command line tool provides i.e batch processing, light weight interfaces for doing powerful things.

## Observations

Command Centre has the View, Report and Configure style interfaces (that we should not mimic).

## Proposed User Experience

## Dashboard

## Cardholder management

- List cardholders
- Create cardholder
Expand All @@ -12,8 +24,10 @@ Cardholder management
- Detach cards from a cardholder
- Visit details for a cardholder

Alarm management
## Alarm management

- List alarms
- Acknowledge alarms
- Comment on an alarm

## Reporting
19 changes: 17 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ tasks:
dev:textual:
desc: runs the textual cli
cmds:
- poetry run textual --dev --
- poetry run textual -- {{.CLI_ARGS}}
dev:tui:
desc: runs text gallagher console in dev mode
cmds:
- poetry run textual run --dev gallagher.tui:main
- poetry run textual run --dev gallagher.tui
dev:py:
desc: runs python in the poetry shell
cmds:
Expand All @@ -84,4 +84,19 @@ tasks:
http get \
https://commandcentre-api-au.security.gallagher.cloud/api/{{.CLI_ARGS}} \
"Authorization: GGL-API-KEY $GACC_API_KEY"
debug:delete:
prompt: "Are you sure you want to delete {{.CLI_ARGS}}??"
desc: use httpie to delete resource from CC
summary: |
runs a httpie get against the gallagher aus gateway
appends the required headers, assumes the environment
variables are set.
you must pass in the partial url (past /api),
along with any parameters.
cmds:
- |
http delete \
https://commandcentre-api-au.security.gallagher.cloud/api/{{.CLI_ARGS}} \
"Authorization: GGL-API-KEY $GACC_API_KEY"
13 changes: 13 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Gallagher Python Toolkit Assets

This directory contains assets for the Gallagher Python Toolkit project. There are two types of files found in here:

- Screenshots from the Command Centre application
- Branding assets for the project

The screenshots are used for documentation purposes and are copyright of Gallagher Group Limited.

The branding assets are used for the project's logo and are copyright of the project's maintainers.

> [!WARNING]
> Please seek appropriate permission before referencing or reusing any of the assets in this directory.
Binary file added assets/cc-bluetooth-enable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-accesszone.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-cardholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-controller-output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-controller.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-door-alarm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-reader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-detail-rest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-list-accessgroup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-list-door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/cc-list-hardware.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wan-7000-cc-config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wan-7000-ip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/wan-7000-ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 206e453

Please sign in to comment.