Package org.rapidcontext.app.model
Class AuthHelper
java.lang.Object
org.rapidcontext.app.model.AuthHelper
Helper methods for handling authentication tokens.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateLoginToken(User user, long expiry) Creates a login token for a user.static StringcreateProcToken(Session session, String appId, String procId) Creates a procedure call token.static UservalidateLoginToken(String token) Validates a login token.static StringvalidateProcToken(String token, String procId) Validates a procedure call token.
-
Method Details
-
createLoginToken
Creates a login token for a user. The token contains the user id, an expiry timestamp and a validation signature.- Parameters:
user- the user to create the token forexpiry- the expiry timestamp (in millis)- Returns:
- the login token
-
validateLoginToken
Validates a login token. This method supports both the new JWT format and the legacy auth token format.- Parameters:
token- the login token- Returns:
- the authenticated user
- Throws:
SecurityException- if the token is invalid or expired
-
createProcToken
Creates a procedure call token. The token contains the session id, the app identifier and the procedure identifier. This can be used to later validate the origin of procedure calls.- Parameters:
session- the user sessionappId- the app identifierprocId- the procedure identifier- Returns:
- the procedure token
-
validateProcToken
Validates a procedure call token.- Parameters:
token- the procedure call tokenprocId- the expected procedure identifier- Returns:
- the app identifier from the token
- Throws:
SecurityException- if the token is invalid or expired
-