This commit is contained in:
@ -10,6 +10,7 @@ import authority from './Authority';
|
||||
import { AuthRequest, AccessSettings } from './AuthHandler';
|
||||
import { debug } from './debug';
|
||||
import { extract_cookie, CookieSettings } from './cookie';
|
||||
import blacklist from './Blacklist';
|
||||
|
||||
const logger = debug ('gateway');
|
||||
|
||||
@ -181,6 +182,27 @@ class GatewayClass {
|
||||
logger ('failed to authenticate, redirecting client');
|
||||
return this.redirect (res);
|
||||
}
|
||||
|
||||
public logout (req: IncomingMessage): void {
|
||||
const l = logger.extend ('logout');
|
||||
l ('invalidating all submitted tokens');
|
||||
const auth_strings = [
|
||||
this.get_header_auth (req),
|
||||
extract_cookie (this._options.cookie?.name, req.headers.cookie),
|
||||
extract_cookie (this._options.refresh_cookie?.name, req.headers.cookie)
|
||||
];
|
||||
const tokens = auth_strings
|
||||
.filter ((v) => v !== null)
|
||||
.map ((v) => authority.verify (v as string))
|
||||
.filter ((v) => v.valid);
|
||||
|
||||
l ('found %d tokens: %O', tokens.length, tokens);
|
||||
|
||||
for (const token of tokens)
|
||||
blacklist.add_signature (token.id);
|
||||
|
||||
l ('complete');
|
||||
}
|
||||
}
|
||||
|
||||
export default function create_gateway (options: GatewayOptions): Gateway {
|
||||
|
Reference in New Issue
Block a user