From 1c81e850a203856229f1c9142387cbec31e18d5f Mon Sep 17 00:00:00 2001 From: derdeka Date: Wed, 26 Feb 2020 00:35:25 +0100 Subject: [PATCH] feat(authentication): extend TokenService for revokeable tokens --- .../src/services/token.service.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/authentication/src/services/token.service.ts b/packages/authentication/src/services/token.service.ts index e2714bd4c9eb..c80c71ec0322 100644 --- a/packages/authentication/src/services/token.service.ts +++ b/packages/authentication/src/services/token.service.ts @@ -11,10 +11,32 @@ import {UserProfile} from '@loopback/security'; export interface TokenService { /** * Verifies the validity of a token string and returns a user profile + * + * @param token The token/secret which should be validated/verified. + * @param userProfile Depending on the token system this optional parameter + * can be used to check if the token is valid for the given user. + * + * @returns The UserProfile which belongs to the given token. */ - verifyToken(token: string): Promise; + verifyToken(token: string, userProfile?: UserProfile): Promise; + /** * Generates a token string based on a user profile + * + * @param userProfile A UserProfile for which a token should be generated. + * + * @returns a generated token/secret for a given UserProfile. */ generateToken(userProfile: UserProfile): Promise; + + /** + * Revokes a given token (if supported by token system) + * + * @param token The token/secret which should be revoked/invalidated. + * @param userProfile An optional UserProfile to check if the token + * is valid for a given User. + * + * @returns true, if the given token was invalidated. + */ + revokeToken?(token: string, userProfile?: UserProfile): Promise; }