ab-bff-service 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ab_bff_service-0.2.0/.gitignore +213 -0
- ab_bff_service-0.2.0/LICENSE +21 -0
- ab_bff_service-0.2.0/PKG-INFO +209 -0
- ab_bff_service-0.2.0/README.md +190 -0
- ab_bff_service-0.2.0/pyproject.toml +76 -0
- ab_bff_service-0.2.0/src/ab_service/bff/__init__.py +0 -0
- ab_bff_service-0.2.0/src/ab_service/bff/main.py +55 -0
- ab_bff_service-0.2.0/src/ab_service/bff/routes/__init__.py +0 -0
- ab_bff_service-0.2.0/src/ab_service/bff/routes/identity_context.py +20 -0
@@ -0,0 +1,213 @@
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
2
|
+
__pycache__/
|
3
|
+
*.py[codz]
|
4
|
+
*$py.class
|
5
|
+
|
6
|
+
# C extensions
|
7
|
+
*.so
|
8
|
+
|
9
|
+
# Distribution / packaging
|
10
|
+
.Python
|
11
|
+
build/
|
12
|
+
develop-eggs/
|
13
|
+
dist/
|
14
|
+
downloads/
|
15
|
+
eggs/
|
16
|
+
.eggs/
|
17
|
+
lib/
|
18
|
+
lib64/
|
19
|
+
parts/
|
20
|
+
sdist/
|
21
|
+
var/
|
22
|
+
wheels/
|
23
|
+
share/python-wheels/
|
24
|
+
*.egg-info/
|
25
|
+
.installed.cfg
|
26
|
+
*.egg
|
27
|
+
MANIFEST
|
28
|
+
|
29
|
+
# PyInstaller
|
30
|
+
# Usually these files are written by a python script from a template
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32
|
+
*.manifest
|
33
|
+
*.spec
|
34
|
+
|
35
|
+
# Installer logs
|
36
|
+
pip-log.txt
|
37
|
+
pip-delete-this-directory.txt
|
38
|
+
|
39
|
+
# Unit test / coverage reports
|
40
|
+
htmlcov/
|
41
|
+
.tox/
|
42
|
+
.nox/
|
43
|
+
.coverage
|
44
|
+
.coverage.*
|
45
|
+
.cache
|
46
|
+
nosetests.xml
|
47
|
+
coverage.xml
|
48
|
+
*.cover
|
49
|
+
*.py.cover
|
50
|
+
.hypothesis/
|
51
|
+
.pytest_cache/
|
52
|
+
cover/
|
53
|
+
|
54
|
+
# Translations
|
55
|
+
*.mo
|
56
|
+
*.pot
|
57
|
+
|
58
|
+
# Django stuff:
|
59
|
+
*.log
|
60
|
+
local_settings.py
|
61
|
+
db.sqlite3
|
62
|
+
db.sqlite3-journal
|
63
|
+
|
64
|
+
# Flask stuff:
|
65
|
+
instance/
|
66
|
+
.webassets-cache
|
67
|
+
|
68
|
+
# Scrapy stuff:
|
69
|
+
.scrapy
|
70
|
+
|
71
|
+
# Sphinx documentation
|
72
|
+
docs/_build/
|
73
|
+
|
74
|
+
# PyBuilder
|
75
|
+
.pybuilder/
|
76
|
+
target/
|
77
|
+
|
78
|
+
# Jupyter Notebook
|
79
|
+
.ipynb_checkpoints
|
80
|
+
|
81
|
+
# IPython
|
82
|
+
profile_default/
|
83
|
+
ipython_config.py
|
84
|
+
|
85
|
+
# pyenv
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
88
|
+
.python-version
|
89
|
+
|
90
|
+
# pipenv
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94
|
+
# install all needed dependencies.
|
95
|
+
Pipfile.lock
|
96
|
+
|
97
|
+
# UV
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100
|
+
# commonly ignored for libraries.
|
101
|
+
uv.lock
|
102
|
+
|
103
|
+
# poetry
|
104
|
+
# For packages, we do not commit the lock file,
|
105
|
+
# since we are not controlling the environment,
|
106
|
+
# refer to https://python-poetry.org/docs/basic-usage/#as-a-library-developer
|
107
|
+
poetry.lock
|
108
|
+
poetry.toml
|
109
|
+
|
110
|
+
# pdm
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
112
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
113
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
114
|
+
pdm.lock
|
115
|
+
pdm.toml
|
116
|
+
.pdm-python
|
117
|
+
.pdm-build/
|
118
|
+
|
119
|
+
# pixi
|
120
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
121
|
+
pixi.lock
|
122
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
123
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
124
|
+
.pixi
|
125
|
+
|
126
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
127
|
+
__pypackages__/
|
128
|
+
|
129
|
+
# Celery stuff
|
130
|
+
celerybeat-schedule
|
131
|
+
celerybeat.pid
|
132
|
+
|
133
|
+
# SageMath parsed files
|
134
|
+
*.sage.py
|
135
|
+
|
136
|
+
# Environments
|
137
|
+
.env
|
138
|
+
.envrc
|
139
|
+
.venv
|
140
|
+
env/
|
141
|
+
venv/
|
142
|
+
ENV/
|
143
|
+
env.bak/
|
144
|
+
venv.bak/
|
145
|
+
|
146
|
+
# Spyder project settings
|
147
|
+
.spyderproject
|
148
|
+
.spyproject
|
149
|
+
|
150
|
+
# Rope project settings
|
151
|
+
.ropeproject
|
152
|
+
|
153
|
+
# mkdocs documentation
|
154
|
+
/site
|
155
|
+
|
156
|
+
# mypy
|
157
|
+
.mypy_cache/
|
158
|
+
.dmypy.json
|
159
|
+
dmypy.json
|
160
|
+
|
161
|
+
# Pyre type checker
|
162
|
+
.pyre/
|
163
|
+
|
164
|
+
# pytype static type analyzer
|
165
|
+
.pytype/
|
166
|
+
|
167
|
+
# Cython debug symbols
|
168
|
+
cython_debug/
|
169
|
+
|
170
|
+
# PyCharm
|
171
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
172
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
173
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
174
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
175
|
+
#.idea/
|
176
|
+
|
177
|
+
# Abstra
|
178
|
+
# Abstra is an AI-powered process automation framework.
|
179
|
+
# Ignore directories containing user credentials, local state, and settings.
|
180
|
+
# Learn more at https://abstra.io/docs
|
181
|
+
.abstra/
|
182
|
+
|
183
|
+
# Visual Studio Code
|
184
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
185
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
186
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
187
|
+
# you could uncomment the following to ignore the entire vscode folder
|
188
|
+
#.vscode/
|
189
|
+
|
190
|
+
# Ruff stuff:
|
191
|
+
.ruff_cache/
|
192
|
+
|
193
|
+
# PyPI configuration file
|
194
|
+
.pypirc
|
195
|
+
|
196
|
+
# Cursor
|
197
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
198
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
199
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
200
|
+
.cursorignore
|
201
|
+
.cursorindexingignore
|
202
|
+
|
203
|
+
# Marimo
|
204
|
+
marimo/_static/
|
205
|
+
marimo/_lsp/
|
206
|
+
__marimo__/
|
207
|
+
|
208
|
+
# Streamlit
|
209
|
+
.streamlit/secrets.toml
|
210
|
+
|
211
|
+
# Generated Files
|
212
|
+
.DS_Store
|
213
|
+
/data
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Matthew Coulter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,209 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: ab-bff-service
|
3
|
+
Version: 0.2.0
|
4
|
+
Summary: Auth Broker BFF Service.
|
5
|
+
Author-email: Matthew Coulter <53892067+mattcoulter7@users.noreply.github.com>
|
6
|
+
License-File: LICENSE
|
7
|
+
Requires-Python: <4,>=3.12
|
8
|
+
Requires-Dist: ab-alembic-auto-migrate<1,>=0.2.0
|
9
|
+
Requires-Dist: ab-client-auth-client>=0.1.0
|
10
|
+
Requires-Dist: ab-client-token-validator>=0.1.0
|
11
|
+
Requires-Dist: ab-client-user>=0.1.0
|
12
|
+
Requires-Dist: ab-database[postgres-async,postgres-sync,sqlite-async]<1,>=0.2.2
|
13
|
+
Requires-Dist: ab-identity-context[fastapi]>=0.1.1
|
14
|
+
Requires-Dist: ab-logging>=0.1.2
|
15
|
+
Requires-Dist: fastapi<0.116,>=0.115.14
|
16
|
+
Requires-Dist: pydantic[email]<3,>=2.11.7
|
17
|
+
Requires-Dist: uvicorn<0.36,>=0.35.0
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
|
20
|
+
<div align="center">
|
21
|
+
|
22
|
+
# Auth Broker BFF
|
23
|
+
|
24
|
+
The template repository for creating python packages, shared across auth-broker.
|
25
|
+
|
26
|
+

|
27
|
+

|
28
|
+

|
29
|
+

|
30
|
+

|
31
|
+

|
32
|
+

|
33
|
+

|
34
|
+

|
35
|
+

|
36
|
+

|
37
|
+

|
38
|
+
|
39
|
+
🦜🕸️
|
40
|
+
|
41
|
+
[](https://github.com/auth-broker/service-template/actions/workflows/ci.yaml)
|
42
|
+
|
43
|
+
</div>
|
44
|
+
|
45
|
+
______________________________________________________________________
|
46
|
+
|
47
|
+
## Table of Contents
|
48
|
+
|
49
|
+
<!-- toc -->
|
50
|
+
|
51
|
+
- [Introduction](#introduction)
|
52
|
+
- [Quick Start](#quick-start)
|
53
|
+
- [Installation](#installation)
|
54
|
+
- [Usage](#usage)
|
55
|
+
- [Formatting and linting](#formatting-and-linting)
|
56
|
+
- [CICD](#cicd)
|
57
|
+
|
58
|
+
<!-- tocstop -->
|
59
|
+
|
60
|
+
______________________________________________________________________
|
61
|
+
|
62
|
+
## Introduction
|
63
|
+
|
64
|
+
This template repository aims to create a reusable package template which
|
65
|
+
streamlines the creation and publishing of isolated python packages in auth-broker.
|
66
|
+
This is aligned with the engineering vision @ auth-broker for better modularisation and
|
67
|
+
reusability of code.
|
68
|
+
|
69
|
+
______________________________________________________________________
|
70
|
+
|
71
|
+
## Quick Start
|
72
|
+
|
73
|
+
Since this is just a package, and not a service, there is no real "run" action.
|
74
|
+
But you can run the tests immediately.
|
75
|
+
|
76
|
+
Here are a list of available commands via make.
|
77
|
+
|
78
|
+
### Bare Metal (i.e. your machine)
|
79
|
+
|
80
|
+
1. `make install` - install the required dependencies.
|
81
|
+
1. `make test` - runs the tests.
|
82
|
+
|
83
|
+
### Docker
|
84
|
+
|
85
|
+
1. `make build-docker` - build the docker image.
|
86
|
+
1. `make run-docker` - run the docker compose services.
|
87
|
+
1. `make test-docker` - run the tests in docker.
|
88
|
+
1. `make clean-docker` - remove all docker containers etc.
|
89
|
+
|
90
|
+
______________________________________________________________________
|
91
|
+
|
92
|
+
## Installation
|
93
|
+
|
94
|
+
### For Dev work on the repo
|
95
|
+
|
96
|
+
Install `uv`, (_if you haven't already_)
|
97
|
+
https://docs.astral.sh/uv/getting-started/installation/#installation-methods
|
98
|
+
|
99
|
+
```shell
|
100
|
+
brew install uv
|
101
|
+
```
|
102
|
+
|
103
|
+
Initialise pre-commit (validates ruff on commit.)
|
104
|
+
|
105
|
+
```shell
|
106
|
+
uv run pre-commit install
|
107
|
+
```
|
108
|
+
|
109
|
+
Install dependencies (including dev dependencies)
|
110
|
+
|
111
|
+
```shell
|
112
|
+
uv sync
|
113
|
+
```
|
114
|
+
|
115
|
+
If you are adding a new dev dependency, please run:
|
116
|
+
|
117
|
+
```shell
|
118
|
+
uv add --dev {your-new-package}
|
119
|
+
```
|
120
|
+
|
121
|
+
### Namespaces
|
122
|
+
|
123
|
+
Packages all share the same namespace `ab_core`. To import this package into
|
124
|
+
your project:
|
125
|
+
|
126
|
+
```python
|
127
|
+
from ab_core.template import placeholder_func
|
128
|
+
```
|
129
|
+
|
130
|
+
We encourage you to make your package available to all of ab via this
|
131
|
+
`ab_core` namespace. The goal is to streamline development, POCs and overall
|
132
|
+
collaboration.
|
133
|
+
|
134
|
+
______________________________________________________________________
|
135
|
+
|
136
|
+
## Usage
|
137
|
+
|
138
|
+
### Adding the dependency to your project
|
139
|
+
|
140
|
+
The library is available on PyPI. You can install it using the following
|
141
|
+
command:
|
142
|
+
|
143
|
+
**Using pip**:
|
144
|
+
|
145
|
+
```shell
|
146
|
+
pip install service-bff
|
147
|
+
```
|
148
|
+
|
149
|
+
**Using UV**
|
150
|
+
|
151
|
+
Note: there is currently no nice way like poetry, hence we still needd to
|
152
|
+
provide the full url. https://github.com/astral-sh/uv/issues/10140
|
153
|
+
|
154
|
+
Add the dependency
|
155
|
+
|
156
|
+
```shell
|
157
|
+
uv add service-bff
|
158
|
+
```
|
159
|
+
|
160
|
+
**Using poetry**:
|
161
|
+
|
162
|
+
Then run the following command to install the package:
|
163
|
+
|
164
|
+
```shell
|
165
|
+
poetry add service-bff
|
166
|
+
```
|
167
|
+
|
168
|
+
### How tos
|
169
|
+
|
170
|
+
**Example Usage**
|
171
|
+
|
172
|
+
```python
|
173
|
+
# Please update this based on your package!
|
174
|
+
|
175
|
+
from ab_core.template import placeholder_func
|
176
|
+
|
177
|
+
|
178
|
+
if __name__ == "__main__":
|
179
|
+
print("This is a placeholder: ", placeholdder_func())
|
180
|
+
```
|
181
|
+
|
182
|
+
______________________________________________________________________
|
183
|
+
|
184
|
+
## Formatting and linting
|
185
|
+
|
186
|
+
We use Ruff as the formatter and linter. The pre-commit has hooks which runs
|
187
|
+
checking and applies linting automatically. The CI validates the linting,
|
188
|
+
ensuring main is always looking clean.
|
189
|
+
|
190
|
+
You can manually use these commands too:
|
191
|
+
|
192
|
+
1. `make lint` - check for linting issues.
|
193
|
+
1. `make format` - fix linting issues.
|
194
|
+
|
195
|
+
______________________________________________________________________
|
196
|
+
|
197
|
+
## CICD
|
198
|
+
|
199
|
+
### Publishing to PyPI
|
200
|
+
|
201
|
+
We publish to PyPI using Github releases. Steps are as follows:
|
202
|
+
|
203
|
+
1. Manually update the version in `pyproject.toml` file using a PR and merge to
|
204
|
+
main. Use `uv version --bump {patch/minor/major}` to update the version.
|
205
|
+
1. Create a new release in Github with the tag name as the version number. This
|
206
|
+
will trigger the `publish` workflow. In the Release window, type in the
|
207
|
+
version number and it will prompt to create a new tag.
|
208
|
+
1. Verify the release in
|
209
|
+
[PyPI](https://pypi.org/project/service-bff/)
|
@@ -0,0 +1,190 @@
|
|
1
|
+
<div align="center">
|
2
|
+
|
3
|
+
# Auth Broker BFF
|
4
|
+
|
5
|
+
The template repository for creating python packages, shared across auth-broker.
|
6
|
+
|
7
|
+

|
8
|
+

|
9
|
+

|
10
|
+

|
11
|
+

|
12
|
+

|
13
|
+

|
14
|
+

|
15
|
+

|
16
|
+

|
17
|
+

|
18
|
+

|
19
|
+
|
20
|
+
🦜🕸️
|
21
|
+
|
22
|
+
[](https://github.com/auth-broker/service-template/actions/workflows/ci.yaml)
|
23
|
+
|
24
|
+
</div>
|
25
|
+
|
26
|
+
______________________________________________________________________
|
27
|
+
|
28
|
+
## Table of Contents
|
29
|
+
|
30
|
+
<!-- toc -->
|
31
|
+
|
32
|
+
- [Introduction](#introduction)
|
33
|
+
- [Quick Start](#quick-start)
|
34
|
+
- [Installation](#installation)
|
35
|
+
- [Usage](#usage)
|
36
|
+
- [Formatting and linting](#formatting-and-linting)
|
37
|
+
- [CICD](#cicd)
|
38
|
+
|
39
|
+
<!-- tocstop -->
|
40
|
+
|
41
|
+
______________________________________________________________________
|
42
|
+
|
43
|
+
## Introduction
|
44
|
+
|
45
|
+
This template repository aims to create a reusable package template which
|
46
|
+
streamlines the creation and publishing of isolated python packages in auth-broker.
|
47
|
+
This is aligned with the engineering vision @ auth-broker for better modularisation and
|
48
|
+
reusability of code.
|
49
|
+
|
50
|
+
______________________________________________________________________
|
51
|
+
|
52
|
+
## Quick Start
|
53
|
+
|
54
|
+
Since this is just a package, and not a service, there is no real "run" action.
|
55
|
+
But you can run the tests immediately.
|
56
|
+
|
57
|
+
Here are a list of available commands via make.
|
58
|
+
|
59
|
+
### Bare Metal (i.e. your machine)
|
60
|
+
|
61
|
+
1. `make install` - install the required dependencies.
|
62
|
+
1. `make test` - runs the tests.
|
63
|
+
|
64
|
+
### Docker
|
65
|
+
|
66
|
+
1. `make build-docker` - build the docker image.
|
67
|
+
1. `make run-docker` - run the docker compose services.
|
68
|
+
1. `make test-docker` - run the tests in docker.
|
69
|
+
1. `make clean-docker` - remove all docker containers etc.
|
70
|
+
|
71
|
+
______________________________________________________________________
|
72
|
+
|
73
|
+
## Installation
|
74
|
+
|
75
|
+
### For Dev work on the repo
|
76
|
+
|
77
|
+
Install `uv`, (_if you haven't already_)
|
78
|
+
https://docs.astral.sh/uv/getting-started/installation/#installation-methods
|
79
|
+
|
80
|
+
```shell
|
81
|
+
brew install uv
|
82
|
+
```
|
83
|
+
|
84
|
+
Initialise pre-commit (validates ruff on commit.)
|
85
|
+
|
86
|
+
```shell
|
87
|
+
uv run pre-commit install
|
88
|
+
```
|
89
|
+
|
90
|
+
Install dependencies (including dev dependencies)
|
91
|
+
|
92
|
+
```shell
|
93
|
+
uv sync
|
94
|
+
```
|
95
|
+
|
96
|
+
If you are adding a new dev dependency, please run:
|
97
|
+
|
98
|
+
```shell
|
99
|
+
uv add --dev {your-new-package}
|
100
|
+
```
|
101
|
+
|
102
|
+
### Namespaces
|
103
|
+
|
104
|
+
Packages all share the same namespace `ab_core`. To import this package into
|
105
|
+
your project:
|
106
|
+
|
107
|
+
```python
|
108
|
+
from ab_core.template import placeholder_func
|
109
|
+
```
|
110
|
+
|
111
|
+
We encourage you to make your package available to all of ab via this
|
112
|
+
`ab_core` namespace. The goal is to streamline development, POCs and overall
|
113
|
+
collaboration.
|
114
|
+
|
115
|
+
______________________________________________________________________
|
116
|
+
|
117
|
+
## Usage
|
118
|
+
|
119
|
+
### Adding the dependency to your project
|
120
|
+
|
121
|
+
The library is available on PyPI. You can install it using the following
|
122
|
+
command:
|
123
|
+
|
124
|
+
**Using pip**:
|
125
|
+
|
126
|
+
```shell
|
127
|
+
pip install service-bff
|
128
|
+
```
|
129
|
+
|
130
|
+
**Using UV**
|
131
|
+
|
132
|
+
Note: there is currently no nice way like poetry, hence we still needd to
|
133
|
+
provide the full url. https://github.com/astral-sh/uv/issues/10140
|
134
|
+
|
135
|
+
Add the dependency
|
136
|
+
|
137
|
+
```shell
|
138
|
+
uv add service-bff
|
139
|
+
```
|
140
|
+
|
141
|
+
**Using poetry**:
|
142
|
+
|
143
|
+
Then run the following command to install the package:
|
144
|
+
|
145
|
+
```shell
|
146
|
+
poetry add service-bff
|
147
|
+
```
|
148
|
+
|
149
|
+
### How tos
|
150
|
+
|
151
|
+
**Example Usage**
|
152
|
+
|
153
|
+
```python
|
154
|
+
# Please update this based on your package!
|
155
|
+
|
156
|
+
from ab_core.template import placeholder_func
|
157
|
+
|
158
|
+
|
159
|
+
if __name__ == "__main__":
|
160
|
+
print("This is a placeholder: ", placeholdder_func())
|
161
|
+
```
|
162
|
+
|
163
|
+
______________________________________________________________________
|
164
|
+
|
165
|
+
## Formatting and linting
|
166
|
+
|
167
|
+
We use Ruff as the formatter and linter. The pre-commit has hooks which runs
|
168
|
+
checking and applies linting automatically. The CI validates the linting,
|
169
|
+
ensuring main is always looking clean.
|
170
|
+
|
171
|
+
You can manually use these commands too:
|
172
|
+
|
173
|
+
1. `make lint` - check for linting issues.
|
174
|
+
1. `make format` - fix linting issues.
|
175
|
+
|
176
|
+
______________________________________________________________________
|
177
|
+
|
178
|
+
## CICD
|
179
|
+
|
180
|
+
### Publishing to PyPI
|
181
|
+
|
182
|
+
We publish to PyPI using Github releases. Steps are as follows:
|
183
|
+
|
184
|
+
1. Manually update the version in `pyproject.toml` file using a PR and merge to
|
185
|
+
main. Use `uv version --bump {patch/minor/major}` to update the version.
|
186
|
+
1. Create a new release in Github with the tag name as the version number. This
|
187
|
+
will trigger the `publish` workflow. In the Release window, type in the
|
188
|
+
version number and it will prompt to create a new tag.
|
189
|
+
1. Verify the release in
|
190
|
+
[PyPI](https://pypi.org/project/service-bff/)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
[build-system]
|
2
|
+
build-backend = "hatchling.build"
|
3
|
+
requires = ["hatchling"]
|
4
|
+
|
5
|
+
[dependency-groups]
|
6
|
+
dev = [
|
7
|
+
"ab-test-fixtures>=0.1.5,<1",
|
8
|
+
"debugpy>=1.8.14,<2",
|
9
|
+
"isort>=6.0.1,<7",
|
10
|
+
"pre-commit>=4.2.0,<5",
|
11
|
+
"pytest-asyncio>=1.0.0,<2",
|
12
|
+
"pytest-cov>=6.2.1,<7",
|
13
|
+
"pytest>=8.4.1,<9",
|
14
|
+
"ruff>=0.12.3,<0.13",
|
15
|
+
"tox>=4.27.0,<5"
|
16
|
+
]
|
17
|
+
|
18
|
+
[project]
|
19
|
+
authors = [{email = "53892067+mattcoulter7@users.noreply.github.com", name = "Matthew Coulter"}]
|
20
|
+
dependencies = [
|
21
|
+
"ab-alembic-auto-migrate>=0.2.0,<1",
|
22
|
+
"ab-database[sqlite-async,postgres-sync,postgres-async]>=0.2.2,<1",
|
23
|
+
"ab-logging>=0.1.2",
|
24
|
+
"ab-identity-context[fastapi]>=0.1.1",
|
25
|
+
"ab-client-token-validator>=0.1.0",
|
26
|
+
"ab-client-user>=0.1.0",
|
27
|
+
"ab-client-auth-client>=0.1.0",
|
28
|
+
"fastapi>=0.115.14,<0.116",
|
29
|
+
"pydantic[email]>=2.11.7,<3",
|
30
|
+
"uvicorn>=0.35.0,<0.36",
|
31
|
+
]
|
32
|
+
description = "Auth Broker BFF Service."
|
33
|
+
name = "ab-bff-service"
|
34
|
+
readme = "README.md"
|
35
|
+
requires-python = ">=3.12, <4"
|
36
|
+
version = "0.2.0"
|
37
|
+
|
38
|
+
[tool.hatch.build.targets.sdist]
|
39
|
+
include = ["src/ab_service"]
|
40
|
+
|
41
|
+
[tool.hatch.build.targets.wheel]
|
42
|
+
include = ["src/ab_service"]
|
43
|
+
|
44
|
+
[tool.hatch.build.targets.wheel.sources]
|
45
|
+
"src/ab_service" = "ab_service"
|
46
|
+
|
47
|
+
[tool.pytest.ini_options]
|
48
|
+
asyncio_default_fixture_loop_scope = "session"
|
49
|
+
asyncio_mode = "auto"
|
50
|
+
markers = [
|
51
|
+
"integration: Assigns the test to the integration test suite.",
|
52
|
+
"regression: Assigns the test to the regression test suite"
|
53
|
+
]
|
54
|
+
|
55
|
+
[tool.ruff]
|
56
|
+
line-length = 120
|
57
|
+
src = ["src"]
|
58
|
+
target-version = "py312"
|
59
|
+
|
60
|
+
[tool.ruff.lint]
|
61
|
+
exclude = [".git", ".venv", "__pycache__", "proto"]
|
62
|
+
fixable = ["ALL"]
|
63
|
+
ignore = [
|
64
|
+
"D104" # missing docstring in public package
|
65
|
+
]
|
66
|
+
select = [
|
67
|
+
"ARG001", # unused arguments
|
68
|
+
"B", # flake8-bugbear
|
69
|
+
"C4", # flake8-comprehensions
|
70
|
+
"D", # pydocstyle (docstring checks)
|
71
|
+
"E", # pycodestyle errors
|
72
|
+
"F", # pyflakes
|
73
|
+
"I", # isort
|
74
|
+
"UP", # pyupgrade
|
75
|
+
"W" # pycodestyle warnings
|
76
|
+
]
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"""Main application for the User Service."""
|
2
|
+
|
3
|
+
from contextlib import asynccontextmanager
|
4
|
+
from typing import Annotated
|
5
|
+
|
6
|
+
from ab_client_auth_client.client import Client as AuthClient
|
7
|
+
from ab_client_token_validator.client import Client as TokenValidatorClient
|
8
|
+
from ab_client_user.client import Client as UserClient
|
9
|
+
from ab_core.alembic_auto_migrate.service import AlembicAutoMigrate
|
10
|
+
from ab_core.database.databases import Database
|
11
|
+
from ab_core.dependency import Depends, inject
|
12
|
+
from ab_core.dependency.loaders.environment_object import ObjectLoaderEnvironment
|
13
|
+
from ab_core.logging.config import LoggingConfig
|
14
|
+
from fastapi import FastAPI
|
15
|
+
|
16
|
+
from ab_service.bff.routes.identity_context import router as identity_context_router
|
17
|
+
|
18
|
+
|
19
|
+
@inject
|
20
|
+
@asynccontextmanager
|
21
|
+
async def lifespan(
|
22
|
+
_app: FastAPI,
|
23
|
+
_db: Annotated[
|
24
|
+
Database,
|
25
|
+
Depends(Database, persist=True),
|
26
|
+
], # cold start load db into cache
|
27
|
+
logging_config: Annotated[
|
28
|
+
LoggingConfig,
|
29
|
+
Depends(LoggingConfig, persist=True),
|
30
|
+
],
|
31
|
+
alembic_auto_migrate: Annotated[
|
32
|
+
AlembicAutoMigrate,
|
33
|
+
Depends(AlembicAutoMigrate, persist=True),
|
34
|
+
],
|
35
|
+
_auth_client: Annotated[
|
36
|
+
AuthClient,
|
37
|
+
Depends(ObjectLoaderEnvironment[AuthClient](env_prefix="AUTH_SERVICE"), persist=True),
|
38
|
+
],
|
39
|
+
_token_validator_client: Annotated[
|
40
|
+
TokenValidatorClient,
|
41
|
+
Depends(ObjectLoaderEnvironment[TokenValidatorClient](env_prefix="TOKEN_VALIDATOR_SERVICE"), persist=True),
|
42
|
+
],
|
43
|
+
_user_client: Annotated[
|
44
|
+
UserClient,
|
45
|
+
Depends(ObjectLoaderEnvironment[UserClient](env_prefix="USER_SERVICE"), persist=True),
|
46
|
+
],
|
47
|
+
):
|
48
|
+
"""Lifespan context manager to handle startup and shutdown events."""
|
49
|
+
logging_config.apply()
|
50
|
+
alembic_auto_migrate.run()
|
51
|
+
yield
|
52
|
+
|
53
|
+
|
54
|
+
app = FastAPI(lifespan=lifespan)
|
55
|
+
app.include_router(identity_context_router)
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"""User-related API routes."""
|
2
|
+
|
3
|
+
from typing import Annotated
|
4
|
+
|
5
|
+
from ab_core.database.session_context import db_session_async
|
6
|
+
from ab_core.identity_context.dependency import IdentityContext, get_identity_context
|
7
|
+
from fastapi import APIRouter
|
8
|
+
from fastapi import Depends as FDepends
|
9
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
10
|
+
|
11
|
+
router = APIRouter(prefix="/identity-context", tags=["Identity Context"])
|
12
|
+
|
13
|
+
|
14
|
+
@router.get("", response_model=IdentityContext)
|
15
|
+
async def me(
|
16
|
+
_db_session: Annotated[AsyncSession, FDepends(db_session_async)],
|
17
|
+
identity_context: Annotated[IdentityContext, FDepends(get_identity_context)],
|
18
|
+
):
|
19
|
+
"""Return the current user's identity context."""
|
20
|
+
return identity_context
|