Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2023.09.1 #330

Merged
merged 45 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fa7370d
chore(deps-dev): bump flask from 2.3.2 to 2.3.3
dependabot[bot] Aug 22, 2023
0517cb0
fix(terraform): disable always_on
thekaveman Aug 30, 2023
d697492
Fix: disable app service AlwaysOn (#309)
thekaveman Aug 30, 2023
4816ed2
refactor: split out pipeline into two stages
angela-tran Aug 31, 2023
b988758
feat: add support for tag-based trigger
angela-tran Aug 31, 2023
3610f01
fix: make PR trigger also only happen for Terraform file changes
angela-tran Aug 31, 2023
eca6eef
refactor: simplify condition by consolidating 'or' expression
angela-tran Aug 31, 2023
fc8a431
Feat: infra pipeline tag trigger (#310)
angela-tran Aug 31, 2023
9c78e78
chore(deps): bump actions/checkout from 3 to 4
dependabot[bot] Sep 4, 2023
2394700
chore(deps): bump actions/checkout from 3 to 4 (#311)
thekaveman Sep 5, 2023
5de156a
chore(deps-dev): bump flask from 2.3.2 to 2.3.3 (#308)
machikoyasuda Sep 7, 2023
e5f67db
chore(deps-dev): bump flask-sqlalchemy from 3.0.5 to 3.1.0
dependabot[bot] Sep 11, 2023
e38cf8b
chore(deps-dev): bump flask-sqlalchemy from 3.0.5 to 3.1.0 (#313)
machikoyasuda Sep 11, 2023
1523110
chore(deps-dev): bump flask-sqlalchemy from 3.1.0 to 3.1.1
dependabot[bot] Sep 12, 2023
11bee15
chore(deps): bump docker/login-action from 2 to 3
dependabot[bot] Sep 12, 2023
a9b1fa4
chore(deps): bump docker/build-push-action from 4 to 5
dependabot[bot] Sep 12, 2023
e3886b2
chore(deps): bump docker/setup-buildx-action from 2 to 3
dependabot[bot] Sep 12, 2023
40e7844
chore(deps-dev): bump flask-sqlalchemy from 3.1.0 to 3.1.1 (#314)
machikoyasuda Sep 12, 2023
57d2cec
chore(deps): bump docker/build-push-action from 4 to 5 (#316)
thekaveman Sep 14, 2023
5f08d3e
chore(deps): bump docker/setup-buildx-action from 2 to 3 (#317)
thekaveman Sep 14, 2023
1b94a13
chore(deps): bump docker/login-action from 2 to 3 (#315)
thekaveman Sep 14, 2023
f250a36
chore(devcontainer): use black/flake8 extensions
thekaveman Sep 14, 2023
68dd16f
chore(devcontainer): simplify build
thekaveman Sep 14, 2023
f459b64
Chore: devcontainer cleanup (#318)
thekaveman Sep 15, 2023
d009dac
chore(pre-commit): autoupdate hooks
pre-commit-ci[bot] Sep 11, 2023
870b19b
feat(settings): add config item for request timeout
thekaveman Sep 14, 2023
58144e7
fix: use config timeout for all requests
thekaveman Sep 14, 2023
e4194e6
fix(docs): remove broken/unused extension
thekaveman Sep 15, 2023
4635f5a
Fix: add requests timeout (#321)
thekaveman Sep 15, 2023
72ae4f1
chore(deps-dev): bump eligibility-api from 2023.6.1 to 2023.9.1
dependabot[bot] Sep 18, 2023
1730445
chore(deps-dev): bump eligibility-api from 2023.6.1 to 2023.9.1 (#324)
thekaveman Sep 18, 2023
2cff2e5
chore(version): manage string in pyproject
thekaveman Sep 18, 2023
35c552b
chore: normalize pyproject structure
thekaveman Sep 18, 2023
ba6f113
docs(configuration): creating keypairs
thekaveman Sep 15, 2023
f2c82df
Chore: version management (#325)
thekaveman Sep 19, 2023
24e7c3a
chore: update to Python 3.11, handle new behavior with csv 'quotechar'
angela-tran Sep 19, 2023
a4ad552
chore: update Python version for GitHub workflows
angela-tran Sep 19, 2023
774c210
chore: update Black target version to 3.11
angela-tran Sep 19, 2023
a639af7
Chore: update to Python 3.11 (#326)
angela-tran Sep 19, 2023
1da2d98
chore(pre-commit): autoupdate hooks
pre-commit-ci[bot] Sep 25, 2023
2d5fafe
chore(pre-commit): autoupdate hooks (#327)
thekaveman Sep 26, 2023
bf38280
Fix: docs dependencies and keypair configuration (#320)
thekaveman Sep 26, 2023
5204fa2
fix(settings): match default timeout to benefits
thekaveman Sep 26, 2023
b5da25e
Fix: match default timeout to benefits (#328)
thekaveman Sep 26, 2023
bd9404f
Deploy to test (#323)
thekaveman Sep 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM eligibility_server:latest

# install devcontainer requirements
RUN pip install -e .[dev,test]

# docs requirements are in a separate file for the GitHub Action
COPY docs/requirements.txt docs/requirements.txt
RUN pip install --no-cache-dir -r docs/requirements.txt

# install devcontainer requirements
RUN pip install -e .[dev,test]

# install pre-commit environments in throwaway Git repository
# https://stackoverflow.com/a/68758943
COPY .pre-commit-config.yaml .
Expand Down
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"runServices": ["dev", "docs"],
"workspaceFolder": "/home/calitp/app",
"postStartCommand": ["/bin/bash", "bin/init.sh"],
"postAttachCommand": ["/bin/bash", ".devcontainer/postAttach.sh"],

"customizations": {
// Set *default* container specific settings.json values on container create.
"vscode": {
Expand All @@ -27,7 +25,9 @@
"hashicorp.terraform",
"mhutchie.git-graph",
"ms-python.python",
"ms-python.vscode-pylance"
"ms-python.black-formatter",
"ms-python.flake8",
"tamasfe.even-better-toml"
]
}
}
Expand Down
5 changes: 0 additions & 5 deletions .devcontainer/postAttach.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/.python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10
3.11
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Docker Login to GitHub Container Registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
uses: docker/setup-buildx-action@v3

- name: Build, tag, and push image to GitHub Container Registry
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
build-args: GIT-SHA=${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ MD024: false

# Allow inline HTML
MD033: false

# Allow fenced code blocks
MD046: false
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default_stages:

repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
rev: v2.4.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand All @@ -33,27 +33,27 @@ repos:
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.9.1
hooks:
- id: black
types:
- python

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
types:
- python

- repo: https://github.com/pycqa/bandit
rev: 1.7.4
rev: 1.7.5
hooks:
- id: bandit
args: ["-ll"]
files: .py$

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
rev: v0.37.0
hooks:
- id: markdownlint
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"[python]": {
"editor.defaultFormatter": "ms-python.python"
"editor.defaultFormatter": "ms-python.black-formatter"
},
"python.formatting.provider": "black",
"python.formatting.provider": "none",
"python.languageServer": "Pylance",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
Expand Down
34 changes: 31 additions & 3 deletions docs/configuration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,35 @@ If you want to run with different settings, you should:
1. Set the `ELIGIBILITY_SERVER_SETTINGS` environment variable to the path of your new file

!!! note
The Eligibility server loads in settings using Flask's methods for [Configuration Handling](https://flask.palletsprojects.com/en/2.2.x/config/).

!!! important
The default settings that will always be loaded are in [eligibility_server/settings.py](https://github.com/cal-itp/eligibility-server/blob/dev/eligibility_server/settings.py)
The Eligibility server loads in settings using Flask's methods for [Configuration Handling](https://flask.palletsprojects.com/en/2.3.x/config/).

!!! note

The default settings that will always be loaded are in [eligibility_server/settings.py](https://github.com/cal-itp/eligibility-server/blob/dev/eligibility_server/settings.py)

## Creating a new keypair

!!! warning

The sample keys cannot be used for production. You must create and use a new keypair.

To create a new keypair, start by creating the private key e.g. using [OpenSSL](https://www.openssl.org/docs/man3.1/man1/openssl-genrsa.html):

```console
openssl genrsa -out private.pem -traditional 4096
```

Next, extract the public key e.g. using [OpenSSL](https://www.openssl.org/docs/man3.1/man1/openssl-rsa.html):

```console
openssl rsa -in private.pem -pubout -out public.pem
```

Now there are two files:

- The private key, kept secret for this server instance only: `private.pem`
- The public key, shared with all clients of this server: `public.pem`

The server instance also needs a public key reference from its client, so the above process should be repeated on the client-
side and the client's _public key_ should be shared with the server.
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fontawesome_markdown
mkdocs
mkdocs-awesome-pages-plugin
mkdocs-macros-plugin
Expand Down
8 changes: 6 additions & 2 deletions eligibility_server/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
__version__ = "2023.08.2"
from importlib.metadata import version, PackageNotFoundError

VERSION = __version__
try:
__version__ = version("eligibility-server")
except PackageNotFoundError:
# package is not installed
pass
6 changes: 3 additions & 3 deletions eligibility_server/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def import_json_users(json_path, remote):
data = {}
if remote:
# download the file to a dict
data = requests.get(json_path).json()
data = requests.get(json_path, timeout=config.request_timeout).json()
else:
# open the file and load to a dict
with open(json_path) as file:
Expand All @@ -82,7 +82,7 @@ def import_csv_users(csv_path, remote):
temp_csv = None
if remote:
# download the content as text and write to a temp file
content = requests.get(csv_path).text
content = requests.get(csv_path, timeout=config.request_timeout).text
# note we leave the temp file open so it exists later for reading
temp_csv = NamedTemporaryFile(mode="w", encoding="utf-8")
temp_csv.write(content)
Expand All @@ -98,7 +98,7 @@ def import_csv_users(csv_path, remote):
file,
delimiter=config.csv_delimiter,
quoting=config.csv_quoting,
quotechar=config.csv_quotechar,
quotechar=config.csv_quotechar if config.csv_quotechar else None,
)

for row in data:
Expand Down
2 changes: 1 addition & 1 deletion eligibility_server/keypair.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def _read_key_file(key_path):
return _CACHE[key_path]

if key_path.startswith("http"):
data = requests.get(key_path).text
data = requests.get(key_path, timeout=config.request_timeout).text
key = data.encode("utf8")
else:
with open(key_path, "rb") as pemfile:
Expand Down
5 changes: 5 additions & 0 deletions eligibility_server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
DEBUG_MODE = True
HOST = "0.0.0.0" # nosec
LOG_LEVEL = "INFO"
REQUEST_TIMEOUT = (3, 20)

# Database settings

Expand Down Expand Up @@ -62,6 +63,10 @@ def host(self):
def log_level(self):
return str(current_app.config["LOG_LEVEL"])

@property
def request_timeout(self):
return current_app.config["REQUEST_TIMEOUT"]

# API settings

@property
Expand Down
4 changes: 3 additions & 1 deletion keys/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# keys

*These keys are just samples*. They cannot be used for production systems.
_These keys are just samples_. They cannot be used for production systems.

See more at <https://docs.calitp.org/eligibility-server/configuration>
1 change: 0 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,3 @@ markdown_extensions:
# insert a blank space before the character
permalink: " ¶"
- smarty
- fontawesome_markdown
33 changes: 17 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

[project]
classifiers = ["Programming Language :: Python :: 3 :: Only"]
name = "eligibility-server"
version = "2023.09.1"
description = "Server implementation of the Eligibility Verification API"
readme = "README.md"
license = { file = "LICENSE" }
classifiers = ["Programming Language :: Python :: 3 :: Only"]
requires-python = ">=3.9"
dependencies = [
"eligibility-api==2023.6.1",
"Flask==2.3.2",
"eligibility-api==2023.9.1",
"Flask==2.3.3",
"Flask-RESTful==0.3.10",
"Flask-SQLAlchemy==3.0.5",
"Flask-SQLAlchemy==3.1.1",
"requests==2.31.0"
]
dynamic = ["version"]
keywords = ["flask"]
license = { file = "LICENSE" }
name = "eligibility-server"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
Expand All @@ -36,11 +31,17 @@ Code = "https://github.com/cal-itp/eligibility-server"
Documentation = "https://docs.calitp.org/eligibility-server"
Issues = "https://github.com/cal-itp/eligibility-server/issues"

# Configuration for black
[build-system]
requires = ["setuptools>=65", "wheel"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 127
target-version = ['py310']
target-version = ['py311']
include = '\.pyi?$'

[tool.pyright]
include = ["eligibility_server", "tests"]

[tool.setuptools]
packages = ["eligibility_server"]
1 change: 1 addition & 0 deletions terraform/app_service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resource "azurerm_linux_web_app" "main" {
https_only = true

site_config {
always_on = false
ftps_state = "Disabled"
http2_enabled = true

Expand Down
Loading