SQLPage: infinite login loop in OIDC when the ID token is large

summary

If you’re stuck in an infinite OIDC login loop, the likely cause is an ID token that’s too large for your browser’s cookie limits. This prevents the token from being stored, causing repeated authentication attempts.

To fix it, reduce your ID token’s size by:

  • Requesting fewer OIDC scopes from your Identity Provider (IdP).
  • Configuring your IdP to avoid embedding large data (like inline images) directly into the token’s claims.

Consult your Identity Provider’s documentation for specific settings to control token size.

Introduction

I’m very excited about your new OIDC support in v0.35.1. I’m just having a little trouble getting it to work with Nextcloud OIDC Identity Provider (which I am using successfully with several other apps). I may be configuring something wrong or found an example that does not work with this new feature of SQLPage.

To Reproduce

Install SQLPage v0.35.1 on a VPS Server with the following specs: Ubuntu 22.04 Nginx 1.18.0

  • Reverse Proxy following SQLPage Installation Instructions
    • No URL Rewriting
    • No Multiple Applications
    • No IP Rate Limiting
    • No Static File Serving
    • No Caching or Buffering

Nextcloud OIDC Identity Provider Options

  • Redirection URI: https://my.sqlpage.app/sqlpage/oidc_callback
  • Client Identifier: long-client_id_here
  • Secret: long_client_secret_here
  • Signing Algorithm: RS256 (Alternatively, I could select ‘HS256’)
  • Type: Confidential (Alternatively, I could select ‘Public’)
  • Flows Code Authorization Flow (Alternatively, ‘Code & Implicit Authorization Flow’)
  • Access Token Type: Opaque Access Token (Alternatively, ‘JWT Access Token (RFC9068)’)
  • Limited To Groups: No Limit (This is used internally to Nextcloud)

SQLPage Installation

  • binary in /usr/bin
  • web root in /var/www/sqlpage
  • sqlpage.json contents (in /var/www/sqlpage/sqlpage): `{ “database_url”: “mssql://db_user:db_password@db_url/db_schema?encrypt=true”, “oidc_issuer_url”: “https://my.nextcloud.instance”, “oidc_client_id”: “long_client_id_here”, “oidc_client_secret”: “long_client_secret_here”, “oidc_scopes”: “openid profile email roles groups”, “host”: “my.sqlpage.app”, “listen_on”: “localhost:3712” }

Actual behavior

Without the OIDC parameters:

  • The SQLPage server starts successfully.
  • The custom domain finds the IP.
  • Nginx reverse proxy finds the SQLPage server.
  • The database connects securely.
  • The page loads successfully with data from the database.

With the OIDC parameters:

Expected behavior

I’d like it to connect securely using our Nextcloud OIDC Identity Provider.

Version information

  • OS: Ubuntu 22.04
  • Database [e.g. SQLite, Postgres]: MSSql
  • SQLPage Version [reported by server statup]: v0.35.1

Additional context

Please let me know if there are specific settings I should be setting on the Nextcloud side to work with your product. I’m willing to run any tests to help troubleshoot this great new feature!

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17

Commits related to this issue

Most upvoted comments

You can use https://sql-page.com/functions.sql?function=user_info_token with your database’s json functions

Thank you!

Just in case someone finds this searching for Nextcloud OIDC, here’s an example that worked for me with MSSQL Database:

SELECT ‘list’ AS component, ‘OIDC’ AS title; SELECT ‘Address’ AS title, Address AS description FROM OpenJson(sqlpage.user_info_token()) WITH (Address VARCHAR(200) ‘$.address.formatted’);

You can use https://sql-page.com/functions.sql?function=user_info_token with your database’s json functions

You are correct! Upgrading to Nextcloud OIDC 1.7.1 resolved the problem.

I’ve removed all the changes to the nginx proxy buffer configuration and it works as designed. I was able to access each piece of data in the “profile” scope using sqlpage.user_info().

Thank you for all your help. I’m really enjoying this simple, yet powerful product.