mirror of
https://github.com/EddieTheCubeHead/Stagnum.git
synced 2026-04-26 06:05:49 +03:00
[PR #55] [MERGED] 43 create login routes and auth functionality for backend #258
Labels
No labels
bug
bug
client
design
documentation
feature
feature
infrastructure
pull-request
ready for development
server
server
spike
technical work
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/Stagnum#258
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/EddieTheCubeHead/Stagnum/pull/55
Author: @EddieTheCubeHead
Created: 2/4/2024
Status: ✅ Merged
Merged: 2/6/2024
Merged by: @EddieTheCubeHead
Base:
master← Head:43-create-login-routes-and-auth-functionality-for-backend📝 Commits (10+)
160c19943 Test configuring and fixture creation592df05Tests and functionality for including state in login redirect41f91cc43 database objects now have creation timestamp + tests50dd9d543 refactoring database testing1646d7043 More test refactoring7bb265043 Test for storing login state in databasef520d9dMerge branch 'master' into 43-create-login-routes-and-auth-functionality-for-backend46efc6843 remove redundant dependency holder32ac90643 Test for getting redirect uri from client077a09a43 Get spotify client id from env test and functionality📊 Changes
23 files changed (+772 additions, -63 deletions)
View changed files
📝
server/README.md(+36 -15)📝
server/requirements.txt(+3 -1)➕
server/src/alembic/versions/149e2197ecff_add_data_required_for_login_and_auth_.py(+33 -0)📝
server/src/alembic/versions/af9978211950_add_user_table.py(+2 -2)📝
server/src/api/application.py(+11 -9)📝
server/src/api/auth/__init__.py(+1 -0)➕
server/src/api/auth/dependencies.py(+42 -0)📝
server/src/api/auth/models.py(+1 -1)📝
server/src/api/auth/routes.py(+43 -5)➕
server/src/api/auth/scheduler.py(+29 -0)➕
server/src/api/common/dependencies.py(+102 -0)📝
server/src/api/common/models.py(+7 -0)📝
server/src/database/database_connection.py(+22 -2)📝
server/src/database/entities.py(+11 -2)📝
server/src/main.py(+3 -2)➕
server/test/auth_features/__init__.py(+0 -0)➕
server/test/auth_features/auth_login_callback_features.py(+213 -0)➕
server/test/auth_features/auth_login_features.py(+84 -0)➕
server/test/auth_features/cleanup_state_strings_features.py(+46 -0)➕
server/test/auth_features/conftest.py(+20 -0)...and 3 more files
📄 Description
There's a lot here. I will walk the team through what's happening tomorrow in the weekly as well but trying to communicate the most important points:
FastAPI dependency system and tests
We can use FastAPI dependencies to both easily serve required functionality to routes and mock said functionality during testing if needed (database, connection to spotify). For seeing how dependencies work check the FastAPI docs. For a code example, see server/src/api/common/dependencies.
We're grouping dependencies by where they are needed. We should not cross-import dependencies from a feature folder in api. Place shared dependencies in the common folder.
See test/conftest for mocking dependencies. Generally we want all test setup to happen through fixtures, as it both makes it easy to serve setup code to tests and ensures the scopes stay correct (no global state).
Login functionality
We implement two routes for login functionality:
Also added a scheduled task for deleting state (see src/api/auth/routes), and a FastAPI dependency for validating tokens (see src/api/common/dependencies).
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.