complete redesign
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Auth-Server-Helper which is released under MIT.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, January 2021
|
||||
*/
|
||||
|
||||
import http, { IncomingMessage, ServerResponse } from 'http';
|
||||
import { to_b64 } from '@sapphirecode/encoding-helper';
|
||||
import auth from '../../lib/Authority';
|
||||
@ -46,22 +53,37 @@ describe ('auth handler', () => {
|
||||
if (!req.is_basic) {
|
||||
req.invalid ('unknown autorization type');
|
||||
}
|
||||
else if (req.user !== 'foo' || req.password !== 'bar') {
|
||||
req.deny ();
|
||||
}
|
||||
else {
|
||||
else if (req.user === 'foo' && req.password === 'bar') {
|
||||
req.allow_access ({
|
||||
access_token_expires_in: expires_seconds,
|
||||
include_refresh_token: true,
|
||||
refresh_token_expires_in: refresh_expires_seconds
|
||||
});
|
||||
}
|
||||
else if (req.user === 'part' && req.password === 'bar') {
|
||||
req.allow_part (part_expires_seconds, 'two_factor');
|
||||
}
|
||||
else {
|
||||
req.deny ();
|
||||
}
|
||||
}, {
|
||||
cookie_name: 'cookie_jar',
|
||||
refresh: {
|
||||
access_token_expires_in: expires_seconds,
|
||||
refresh_token_expires_in: refresh_expires_seconds,
|
||||
include_refresh_token: true
|
||||
},
|
||||
modules: {
|
||||
two_factor (request) {
|
||||
if (request.body === 'letmein') {
|
||||
request.allow_access ({
|
||||
access_token_expires_in: expires_seconds,
|
||||
include_refresh_token: true,
|
||||
refresh_token_expires_in: refresh_expires_seconds
|
||||
});
|
||||
}
|
||||
else { request.deny (); }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -183,7 +205,7 @@ describe ('auth handler', () => {
|
||||
});
|
||||
|
||||
|
||||
xit ('should process part token', async () => {
|
||||
it ('should process part token', async () => {
|
||||
const resp1 = await get ({ authorization: 'Basic part:bar' });
|
||||
expect (resp1.statusCode)
|
||||
.toEqual (200);
|
||||
@ -195,7 +217,8 @@ describe ('auth handler', () => {
|
||||
check_token (res1.data.part_token as string, 'part_token');
|
||||
|
||||
const resp2 = await get (
|
||||
{ authorization: `Bearer ${res1.data.part_token}` }
|
||||
{ authorization: `Bearer ${res1.data.part_token}` },
|
||||
'letmein'
|
||||
);
|
||||
expect (resp2.statusCode)
|
||||
.toEqual (200);
|
||||
|
@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Auth-Server-Helper which is released under MIT.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, January 2021
|
||||
*/
|
||||
|
||||
import http from 'http';
|
||||
import gateway from '../../lib/Gateway';
|
||||
import authority from '../../lib/Authority';
|
||||
|
Reference in New Issue
Block a user