| Age | Commit message (Collapse) | Author |
|
JWTBearerTokenValidator caches its JWKS key set and only refreshes it
every jwt_refresh_frequency_hours (default 6). On a fresh deployment,
no JWK exists until the first token is issued (keys are generated
lazily in jwks.py), which can happen after the validator was already
constructed with an empty key set -- every token issued before the
next scheduled refresh then failed to validate, even though a usable
key existed on disk by the time the token arrived.
Also fixes _last_jwks_update never being updated after a refresh,
which meant that once the 6-hour window first elapsed, every later
token validation re-read the JWKS directory from disk instead of
using the cache.
Reproduced against a from-scratch instance: clear the JWKS directory,
start the server, issue a token via the password grant, then use that
same token immediately on another endpoint -- it was rejected with
invalid_token before this change, and is accepted after it.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
|
|
|
|
JWTBearerToken.__init__ was calling with_db_connection with
app.config["SQL_URI"] (the GeneNetwork MariaDB URI) to look up the
authenticated user and OAuth2 client. gn_libs.sqlite3.with_db_connection
expects a SQLite file path, so passing a MySQL URI causes an
OperationalError: unable to open database file every time a JWT is
validated through require_oauth.acquire().
Use app.config["AUTH_DB"] (the gn-auth SQLite database) for both
lookups. Also normalise the whitespace in the user lookup lambda while
here.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Reviewed-By: Frederick M. Muriithi <fredmanglis@gmail.com>
|
|
The gn_auth.auth.db.sqlite3 module is deprecated and should be
removed. This cleanup goes a ways towards that goal.
|
|
|
|
While we do not actually use the password-flow for authentication on
the system, it is useful for getting tokens when running (integration)
tests against the system. This commit allows the test harness to make
use of the simpler password-flow authentication to get tokens.
|
|
|
|
|
|
|
|
To allow the client to pass flags to the redirect_uri that the
authorisation server has no interest in, check that only the "base"
url (protocol, hostname/netlog and path) are registered, ignoring any
query and fragment parameters.
|
|
|
|
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
|
|
|
|
Create the requests in the class, as appropriate, checking for
content-type.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This reverts commit 5a6dc1fb81bf223750f42f4697f3cd7d86b39e71.
Remove debugging statements and restore original code.
|
|
|
|
|
|
|
|
|
|
|
|
Provide the user with the "Forgot Password" link, if the backend
supports it.
|
|
|
|
We have a similar jwk module in gn2 that does similar functionality.
Moving the newest_jwk_with_rotation function to the module ensures
that there's some consistency between both modules so that when we
ever want to remove the duplication (e.g. by creating some python pip
package) it's easier.
|
|
|
|
|
|
The local sign in request used by gn2 uses json. However, the default
parsing assumes form data, see:
- https://github.com/lepture/authlib/blob/v1.2.0/authlib/integrations/flask_oauth2/authorization_server.py#L72
- https://github.com/lepture/authlib/blob/v1.2.0/authlib/integrations/flask_helpers.py#L5
We create a custom Authorization server that defaults to `use_json=True`
when creating the oauth request object
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
With the key rotation in place, eliminate the use of the
SSL_PRIVATE_KEY configuration which pointed to a specific non-changing
JWK.
|
|
|
|
To help with key rotation, we fetch the latest key, creating a new JWK
in any of the following 2 conditions:
* There is no JWK in the first place
* The "newest" key is older than a specified number of days
|
|
The checks for whether a token is already linked, and then revoking it
and raising an error were causing issues in multi-threaded
environments, where there'd be multiple requests to the auth server
all using an expired token.
This just links the refresh token and avoids the check and revocation
for the time being.
|
|
List any/all existing JWKs that the server currently supports.
|
|
Without the `or` later statements were being evaluated, before the
final value was computed. This commit short-circuits that behaviour.
|
|
|
|
|
|
|
|
If a user provides the correct credentials to login, but they are
unverified, redirect them to the email verification page, where they
are provided with a chance to verify their email, or send a new
verification code.
|