mirror of
https://github.com/photoprism/photoprism.git
synced 2026-03-02 22:57:18 -05:00
SQLite: Cannot use Google OIDC due to dynamic typing #2304
Labels
No labels
ai
android
api
auth
awesome
bug
bug
ci
cli
config
database
declined
deprecated
docker
docs 📚
documents
duplicate
easy
enhancement
enhancement
enhancement
epic
faces
feedback wanted
frontend
hacktoberfest
help wanted
idea
in-progress
incomplete
index
invalid
ios
labels
live
live
low-priority
macos
member-feature
metadata
mobile
nas
needs-analysis
no-coding-required
no-coding-required
observability
performance
places
please-test
plus-feature
priority
pro-feature
question
raspberry-pi
raw
released
released
released
research
resolved
security
sharing
tested
tests
third-party-issue
thumbnails
upgrade
upstream-issue
ux
vector
video
waiting
won't fix
won't fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/photoprism#2304
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?
Originally created by @jbortkiewicz on GitHub (Apr 18, 2025).
Originally assigned to: @jbortkiewicz on GitHub.
1. What is not working as documented?
On PhotoPrism configured with SQLite 3 database and Google OIDC authentication, once an user account is created, then it cannot login second time.
2. How can we reproduce it?
Steps to reproduce the behavior:
docker compose up photoprism3. What behavior do you expect?
User can login with the Google account. The same Google OIDC configuration works properly with MariaDB database.
4. What could be the cause of your problem?
Login status shows an error related to the auth id:
The login error is caused by the fact that
auth_idis stored incorrectly on Sqlite3 database:For comparison on MariaDB:
Manually setting
auth_idfor any number with 20 or more digits, leads to te same results:It seems that, in SQLite case, the ORM layer converts the
auth_idto the integer value and store it in the exponential form.5. Can you provide us with example files for testing, error logs, or screenshots?
Login details are stored in an audit log, however the audit log is not available in the community edition.
6. Which software versions do you use?
(a) PhotoPrism Architecture & Build Number: 250321-57590c48b-Linux-AMD64-Plus
(b) Database Type & Version: SQLite v3.45.1
(c) Operating System Types & Versions: docker image: photoprism/photoprism:latest
(d) Browser Types & Versions: Vivaldi
(e) Ad Blockers, Browser Plugins, and/or Firewall Software? no
7. On what kind of device is PhotoPrism installed?
(a) Device / Processor Type: Intel(R) Celeron(R) N5095 @ 2.00GHz, 16 GB memory detected
(b) Physical Memory & Swap Space in GB: 16 GB RAM
(c) Storage Type: SSD
8. Do you use a Reverse Proxy, Firewall, VPN, or CDN?
nginx/1.27.4
@lastzero commented on GitHub (Apr 18, 2025):
Since SQLite uses a "dynamic" typing system, I believe there is currently no feasible way (other than a dirty hack like adding a text prefix to all IDs) for us to work around this if you want to use SQLite AND OIDC with Google as your Identify Provider:
see https://sqlite.org/datatype3.html
@jbortkiewicz If you know how to do it without dirty hacks and without breaking backwards compatibility, we are open to merging a pull request! 👍
@jbortkiewicz commented on GitHub (Apr 18, 2025):
Oh yes, you are right, the problem is caused by dynamic typing feature of SQLite.
The SQLite has a suport of strict typing, however I haven't found information how to enable it with GORM.
Unfortunately my experience with Golang is less than basic, thus I will be not able to help here and propose a solution other than the prefix hack motioned by you.
@keif888 commented on GitHub (Nov 6, 2025):
I tried a proof of concept to do this using Gorm V2 and SQLite in the Postgres branch which could in theory support this, but in practice it can not.
I manually recreated the auth_users table using the ANY type and STRICT setting to ensure that SQLite wouldn't do the type conversions. I had to use the ANY time on most of the columns to allow the test data to be inserted. When using STRICT only very basic types are supported, which does not include datetime, and blob can't be used for text data as it requires a conversion that SQLite refuses to do.
Once I had the table and data loaded, I attempted to run the users show command against a user john that I had set the auth_id to the number above. (Which was read quite happily out by DB Browser for SQLite so I know it was stored in "string" format not "number" format).
PhotoPrism threw some non resolvable errors from Gorm when it tried to access the auth_users table.
The unsupported Scan is coming from Gorm, and indicates that Gorm treats the ANY datatype as a string, and can't apply the returned data into the struct.
Which means that it will not be possible to fix this problem when using the SQLite database, at the database level.
It will require a hacky, add a magic string at the start/end of an auth_id, to allow this to work.
IMHO, the best (TBC via testing) way to do the hacky is to use Gorm Hooks on BeforeSave, BeforeUpdate and AfterFind which could dynamically handle the addition and removal of the magic strings.
The AuthID struct column would need to be made longer to include the magic string.