ab-user 0.1.3__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.
@@ -0,0 +1,195 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
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
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ #pdm.lock
114
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
115
+ # in version control.
116
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
117
+ .pdm.toml
118
+ .pdm-python
119
+ .pdm-build/
120
+
121
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
122
+ __pypackages__/
123
+
124
+ # Celery stuff
125
+ celerybeat-schedule
126
+ celerybeat.pid
127
+
128
+ # SageMath parsed files
129
+ *.sage.py
130
+
131
+ # Environments
132
+ .env
133
+ .venv
134
+ env/
135
+ venv/
136
+ ENV/
137
+ env.bak/
138
+ venv.bak/
139
+
140
+ # Spyder project settings
141
+ .spyderproject
142
+ .spyproject
143
+
144
+ # Rope project settings
145
+ .ropeproject
146
+
147
+ # mkdocs documentation
148
+ /site
149
+
150
+ # mypy
151
+ .mypy_cache/
152
+ .dmypy.json
153
+ dmypy.json
154
+
155
+ # Pyre type checker
156
+ .pyre/
157
+
158
+ # pytype static type analyzer
159
+ .pytype/
160
+
161
+ # Cython debug symbols
162
+ cython_debug/
163
+
164
+ # PyCharm
165
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
166
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
167
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
168
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
169
+ #.idea/
170
+
171
+ # Abstra
172
+ # Abstra is an AI-powered process automation framework.
173
+ # Ignore directories containing user credentials, local state, and settings.
174
+ # Learn more at https://abstra.io/docs
175
+ .abstra/
176
+
177
+ # Visual Studio Code
178
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
179
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
180
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
181
+ # you could uncomment the following to ignore the entire vscode folder
182
+ # .vscode/
183
+
184
+ # Ruff stuff:
185
+ .ruff_cache/
186
+
187
+ # PyPI configuration file
188
+ .pypirc
189
+
190
+ # Cursor
191
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
192
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
193
+ # refer to https://docs.cursor.com/context/ignore-files
194
+ .cursorignore
195
+ .cursorindexingignore
ab_user-0.1.3/LICENSE ADDED
@@ -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.
ab_user-0.1.3/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: ab-user
3
+ Version: 0.1.3
4
+ Author-email: Matthew Coulter <53892067+mattcoulter7@users.noreply.github.com>
5
+ License-File: LICENSE
6
+ Requires-Python: <4,>=3.12
7
+ Requires-Dist: ab-database<2,>=0.1.2
8
+ Requires-Dist: ab-dependency<2,>=0.1.2
9
+ Description-Content-Type: text/markdown
10
+
11
+ # Open Banking, Opened | User
12
+
13
+ User Package for Open Banking, Opened API packages.
@@ -0,0 +1,3 @@
1
+ # Open Banking, Opened | User
2
+
3
+ User Package for Open Banking, Opened API packages.
@@ -0,0 +1,68 @@
1
+ [build-system]
2
+ build-backend = "hatchling.build"
3
+ requires = ["hatchling"]
4
+
5
+ [dependency-groups]
6
+ dev = [
7
+ "debugpy>=1.8.14,<2",
8
+ "isort>=6.0.1,<7",
9
+ "ab-test-fixtures>=0.1.2,<2",
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-database>=0.1.2,<2",
22
+ "ab-dependency>=0.1.2,<2"
23
+ ]
24
+ description = ""
25
+ name = "ab-user"
26
+ readme = "README.md"
27
+ requires-python = ">=3.12, <4"
28
+ version = "0.1.3"
29
+
30
+ [tool.hatch.build.targets.sdist]
31
+ include = ["src/ab_core"]
32
+
33
+ [tool.hatch.build.targets.wheel]
34
+ include = ["src/ab_core"]
35
+
36
+ [tool.hatch.build.targets.wheel.sources]
37
+ "src/ab_core" = "ab_core"
38
+
39
+ [tool.pytest.ini_options]
40
+ asyncio_default_fixture_loop_scope = "session"
41
+ asyncio_mode = "auto"
42
+ markers = [
43
+ "integration: Assigns the test to the integration test suite.",
44
+ "regression: Assigns the test to the regression test suite"
45
+ ]
46
+
47
+ [tool.ruff]
48
+ line-length = 120
49
+ src = ["src"]
50
+ target-version = "py312"
51
+
52
+ [tool.ruff.lint]
53
+ exclude = [".git", ".venv", "__pycache__", "proto"]
54
+ fixable = ["ALL"]
55
+ ignore = [
56
+ "D104" # missing docstring in public package
57
+ ]
58
+ select = [
59
+ "ARG001", # unused arguments
60
+ "B", # flake8-bugbear
61
+ "C4", # flake8-comprehensions
62
+ "D", # pydocstyle (docstring checks)
63
+ "E", # pycodestyle errors
64
+ "F", # pyflakes
65
+ "I", # isort
66
+ "UP", # pyupgrade
67
+ "W" # pycodestyle warnings
68
+ ]
File without changes
@@ -0,0 +1,22 @@
1
+ from datetime import datetime, timezone
2
+ from typing import Optional
3
+
4
+ from sqlmodel import Field, SQLModel
5
+
6
+ from ab_core.database.mixins.active import ActiveMixin
7
+ from ab_core.database.mixins.created_at import CreatedAtMixin
8
+ from ab_core.database.mixins.id import IDMixin
9
+ from ab_core.database.mixins.updated_at import UpdatedAtMixin
10
+
11
+
12
+ class User(IDMixin, CreatedAtMixin, UpdatedAtMixin, ActiveMixin, SQLModel, table=True):
13
+ __tablename__ = "users"
14
+
15
+ oidc_sub: str = Field(index=True, nullable=False)
16
+ oidc_iss: str = Field(nullable=False)
17
+
18
+ email: Optional[str] = Field(default=None, index=True)
19
+ display_name: Optional[str] = Field(default=None)
20
+ preferred_username: Optional[str] = Field(default=None)
21
+
22
+ last_seen: Optional[datetime] = Field(default_factory=lambda: datetime.now(timezone.utc))
@@ -0,0 +1,74 @@
1
+ from datetime import datetime, timezone
2
+ from typing import Optional
3
+
4
+ from pydantic import BaseModel
5
+ from sqlalchemy import select
6
+ from sqlalchemy.ext.asyncio import AsyncSession
7
+
8
+ from .model import User
9
+
10
+
11
+ class UserService(BaseModel):
12
+ async def get_user_by_oidc(
13
+ self,
14
+ *,
15
+ oidc_sub: str,
16
+ oidc_iss: str,
17
+ db_session: AsyncSession,
18
+ ) -> Optional[User]:
19
+ result = await db_session.execute(
20
+ select(User).where(
21
+ User.oidc_sub == oidc_sub,
22
+ User.oidc_iss == oidc_iss,
23
+ )
24
+ )
25
+ return result.scalar_one_or_none()
26
+
27
+ async def get_user_by_id(
28
+ self,
29
+ *,
30
+ user_id: int,
31
+ db_session: AsyncSession,
32
+ ) -> Optional[User]:
33
+ return await db_session.get(User, user_id)
34
+
35
+ async def seen_user(
36
+ self,
37
+ *,
38
+ user: User,
39
+ db_session: AsyncSession,
40
+ ) -> None:
41
+ user.last_seen = datetime.now(timezone.utc)
42
+ db_session.add(user)
43
+
44
+ async def me(
45
+ self,
46
+ *,
47
+ oidc_sub: str,
48
+ oidc_iss: str,
49
+ email: Optional[str] = None,
50
+ display_name: Optional[str] = None,
51
+ preferred_username: Optional[str] = None,
52
+ db_session: AsyncSession,
53
+ ) -> User:
54
+ user = await self.get_user_by_oidc(
55
+ oidc_sub=oidc_sub,
56
+ oidc_iss=oidc_iss,
57
+ db_session=db_session,
58
+ )
59
+
60
+ if user:
61
+ user.email = email or user.email
62
+ user.display_name = display_name or user.display_name
63
+ user.preferred_username = preferred_username or user.preferred_username
64
+ return user
65
+
66
+ user = User(
67
+ oidc_sub=oidc_sub,
68
+ oidc_iss=oidc_iss,
69
+ email=email,
70
+ display_name=display_name,
71
+ preferred_username=preferred_username,
72
+ )
73
+ db_session.add(user)
74
+ return user