Skip to content

Commit f44cfbb

Browse files
committed
6.1.14 release
- [ENHANCEMENT] added date formatting for headers - [ENHANCEMENT] added cache control public, content length '0' for restful response - [ENHANCEMENT] changing userprincipal cache object to only cache a subset of keys rather than whole object - [ENHANCEMENT] add cache tracing - [ENHANCEMENT] adding api tracing in trace directory - [ENHANCEMENT] adding Ad enabled account check when authenticating user in API - [ENHANCEMENT] adding database tracing - [ENHANCEMENT] removing UserPrincipalForLogging as no longer needed - [ENHANCEMENT] changed root id to correlation id - [ENHANCEMENT] added correlationID as a parameter passed as part of apiRequest params - [ENHANCEMENT] refactored how individual AD object being created - [ENHANCEMENT] removed this function 'ExecuteBulkCopy' function with 'SqlBulkCopyColumnMapping' and refactored code as necessary
1 parent 7c0fa66 commit f44cfbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1421
-287
lines changed

db/TD_API_CACHE_TRACE.sql

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CREATE TABLE [dbo].[TD_API_CACHE_TRACE](
2+
[CCH_ID] [int] IDENTITY(1,1) NOT NULL,
3+
[CCH_CORRELATION_ID] varchar(256) NULL,
4+
[CCH_OBJECT] VARCHAR(MAX) NULL,
5+
[CCH_START_TIME] datetime,
6+
[CCH_DURATION] decimal(10,3) NULL,
7+
[CCH_ACTION] varchar(2048) NULL,
8+
[CCH_SUCCESS] bit,
9+
[CCH_COMPRESSED_SIZE] int,
10+
[CCH_EXPIRES_AT] datetime,
11+
PRIMARY KEY CLUSTERED ([CCH_ID] ASC),
12+
)
13+
GO
14+
EXEC sp_addextendedproperty @name = N'MS_Description',
15+
@value = N'api request correlation id',
16+
@level0type = N'SCHEMA',
17+
@level0name = N'dbo',
18+
@level1type = N'TABLE',
19+
@level1name = N'TD_API_CACHE_TRACE',
20+
@level2type = N'COLUMN',
21+
@level2name = N'CCH_CORRELATION_ID'
22+
GO
23+
EXEC sp_addextendedproperty @name = N'MS_Description',
24+
@value = N'cache object details',
25+
@level0type = N'SCHEMA',
26+
@level0name = N'dbo',
27+
@level1type = N'TABLE',
28+
@level1name = N'TD_API_CACHE_TRACE',
29+
@level2type = N'COLUMN',
30+
@level2name = N'CCH_OBJECT'
31+
GO
32+
EXEC sp_addextendedproperty @name = N'MS_Description',
33+
@value = N'start time of operation',
34+
@level0type = N'SCHEMA',
35+
@level0name = N'dbo',
36+
@level1type = N'TABLE',
37+
@level1name = N'TD_API_CACHE_TRACE',
38+
@level2type = N'COLUMN',
39+
@level2name = N'CCH_START_TIME'
40+
GO
41+
EXEC sp_addextendedproperty @name = N'MS_Description',
42+
@value = N'duration of operation',
43+
@level0type = N'SCHEMA',
44+
@level0name = N'dbo',
45+
@level1type = N'TABLE',
46+
@level1name = N'TD_API_CACHE_TRACE',
47+
@level2type = N'COLUMN',
48+
@level2name = N'CCH_DURATION'
49+
GO
50+
EXEC sp_addextendedproperty @name = N'MS_Description',
51+
@value = N'action type',
52+
@level0type = N'SCHEMA',
53+
@level0name = N'dbo',
54+
@level1type = N'TABLE',
55+
@level1name = N'TD_API_CACHE_TRACE',
56+
@level2type = N'COLUMN',
57+
@level2name = N'CCH_ACTION'
58+
GO
59+
EXEC sp_addextendedproperty @name = N'MS_Description',
60+
@value = N'successful or not',
61+
@level0type = N'SCHEMA',
62+
@level0name = N'dbo',
63+
@level1type = N'TABLE',
64+
@level1name = N'TD_API_CACHE_TRACE',
65+
@level2type = N'COLUMN',
66+
@level2name = N'CCH_SUCCESS'
67+
GO
68+
EXEC sp_addextendedproperty @name = N'MS_Description',
69+
@value = N'object compressed size',
70+
@level0type = N'SCHEMA',
71+
@level0name = N'dbo',
72+
@level1type = N'TABLE',
73+
@level1name = N'TD_API_CACHE_TRACE',
74+
@level2type = N'COLUMN',
75+
@level2name = N'CCH_COMPRESSED_SIZE'
76+
GO
77+
EXEC sp_addextendedproperty @name = N'MS_Description',
78+
@value = N'when cache item expires',
79+
@level0type = N'SCHEMA',
80+
@level0name = N'dbo',
81+
@level1type = N'TABLE',
82+
@level1name = N'TD_API_CACHE_TRACE',
83+
@level2type = N'COLUMN',
84+
@level2name = N'CCH_EXPIRES_AT'

db/TD_API_DATABASE_TRACE.sql

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
CREATE TABLE [dbo].[TD_API_DATABASE_TRACE](
2+
[DBT_ID] [int] IDENTITY(1,1) NOT NULL,
3+
[DBT_CORRELATION_ID] varchar(256) NULL,
4+
[DBT_PROCEDURE_NAME] VARCHAR(1024) NULL,
5+
[DBT_PARAMS] VARCHAR(MAX) NULL,
6+
[DBT_START_TIME] datetime,
7+
[DBT_DURATION] decimal(10,3) NULL,
8+
[DBT_ACTION] varchar(2048) NULL,
9+
[DBT_SUCCESS] bit,
10+
PRIMARY KEY CLUSTERED ([DBT_ID] ASC)
11+
)
12+
13+
GO
14+
EXEC sp_addextendedproperty @name = N'MS_Description',
15+
@value = N'PRIMARY KEY',
16+
@level0type = N'SCHEMA',
17+
@level0name = N'dbo',
18+
@level1type = N'TABLE',
19+
@level1name = N'TD_API_DATABASE_TRACE',
20+
@level2type = N'COLUMN',
21+
@level2name = N'DBT_ID'
22+
GO
23+
EXEC sp_addextendedproperty @name = N'MS_Description',
24+
@value = N'request correlation id',
25+
@level0type = N'SCHEMA',
26+
@level0name = N'dbo',
27+
@level1type = N'TABLE',
28+
@level1name = N'TD_API_DATABASE_TRACE',
29+
@level2type = N'COLUMN',
30+
@level2name = N'DBT_CORRELATION_ID'
31+
GO
32+
EXEC sp_addextendedproperty @name = N'MS_Description',
33+
@value = N'name of the stored procedure',
34+
@level0type = N'SCHEMA',
35+
@level0name = N'dbo',
36+
@level1type = N'TABLE',
37+
@level1name = N'TD_API_DATABASE_TRACE',
38+
@level2type = N'COLUMN',
39+
@level2name = N'DBT_PROCEDURE_NAME'
40+
GO
41+
EXEC sp_addextendedproperty @name = N'MS_Description',
42+
@value = N'input parameters',
43+
@level0type = N'SCHEMA',
44+
@level0name = N'dbo',
45+
@level1type = N'TABLE',
46+
@level1name = N'TD_API_DATABASE_TRACE',
47+
@level2type = N'COLUMN',
48+
@level2name = N'DBT_PARAMS'
49+
GO
50+
EXEC sp_addextendedproperty @name = N'MS_Description',
51+
@value = N'start time of operation',
52+
@level0type = N'SCHEMA',
53+
@level0name = N'dbo',
54+
@level1type = N'TABLE',
55+
@level1name = N'TD_API_DATABASE_TRACE',
56+
@level2type = N'COLUMN',
57+
@level2name = N'DBT_START_TIME'
58+
GO
59+
EXEC sp_addextendedproperty @name = N'MS_Description',
60+
@value = N'duration',
61+
@level0type = N'SCHEMA',
62+
@level0name = N'dbo',
63+
@level1type = N'TABLE',
64+
@level1name = N'TD_API_DATABASE_TRACE',
65+
@level2type = N'COLUMN',
66+
@level2name = N'DBT_DURATION'
67+
GO
68+
EXEC sp_addextendedproperty @name = N'MS_Description',
69+
@value = N'what type of event ',
70+
@level0type = N'SCHEMA',
71+
@level0name = N'dbo',
72+
@level1type = N'TABLE',
73+
@level1name = N'TD_API_DATABASE_TRACE',
74+
@level2type = N'COLUMN',
75+
@level2name = N'DBT_ACTION'
76+
GO
77+
EXEC sp_addextendedproperty @name = N'MS_Description',
78+
@value = N'action successful',
79+
@level0type = N'SCHEMA',
80+
@level0name = N'dbo',
81+
@level1type = N'TABLE',
82+
@level1name = N'TD_API_DATABASE_TRACE',
83+
@level2type = N'COLUMN',
84+
@level2name = N'DBT_SUCCESS'

db/TD_API_TRACE.sql

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
CREATE TABLE [dbo].[TD_API_TRACE](
2+
[TRC_ID] [int] IDENTITY(1,1) NOT NULL,
3+
[TRC_METHOD] varchar(256) NULL,
4+
[TRC_PARAMS] nvarchar(2048) NULL,
5+
[TRC_IP] varchar(15) NULL,
6+
[TRC_USERAGENT] varchar(2048) NULL,
7+
[TRC_USERNAME] nvarchar(256) NULL,
8+
[TRC_DATETIME] datetime NOT NULL,
9+
[TRC_STARTTIME] DATETIME NOT NULL,
10+
[TRC_DURATION] DECIMAL(18,3) NOT NULL,
11+
[TRC_STATUSCODE] INT NOT NULL,
12+
[TRC_MACHINENAME] varchar(256) NOT NULL,
13+
[TRC_REQUEST_TYPE] VARCHAR(50) NOT NULL,
14+
[TRC_REQUEST_VERB] VARCHAR(50) NOT NULL,
15+
[TRC_ERROR_PATH] VARCHAR(1024) NULL,
16+
[TRC_CORRELATION_ID] VARCHAR(1024) null,
17+
[TRC_JSONRPC_ERROR_CODE] int null,
18+
PRIMARY KEY CLUSTERED ([TRC_ID] ASC)
19+
)
20+
21+
GO
22+
EXEC sp_addextendedproperty @name = N'MS_Description',
23+
@value = N'the method that was called',
24+
@level0type = N'SCHEMA',
25+
@level0name = N'dbo',
26+
@level1type = N'TABLE',
27+
@level1name = N'TD_API_TRACE',
28+
@level2type = N'COLUMN',
29+
@level2name = N'TRC_METHOD'
30+
GO
31+
EXEC sp_addextendedproperty @name = N'MS_Description',
32+
@value = N'the parameters that were passed in',
33+
@level0type = N'SCHEMA',
34+
@level0name = N'dbo',
35+
@level1type = N'TABLE',
36+
@level1name = N'TD_API_TRACE',
37+
@level2type = N'COLUMN',
38+
@level2name = N'TRC_PARAMS'
39+
GO
40+
EXEC sp_addextendedproperty @name = N'MS_Description',
41+
@value = N'the ip address of the request',
42+
@level0type = N'SCHEMA',
43+
@level0name = N'dbo',
44+
@level1type = N'TABLE',
45+
@level1name = N'TD_API_TRACE',
46+
@level2type = N'COLUMN',
47+
@level2name = N'TRC_IP'
48+
GO
49+
EXEC sp_addextendedproperty @name = N'MS_Description',
50+
@value = N'the useragent of the request (browser)',
51+
@level0type = N'SCHEMA',
52+
@level0name = N'dbo',
53+
@level1type = N'TABLE',
54+
@level1name = N'TD_API_TRACE',
55+
@level2type = N'COLUMN',
56+
@level2name = N'TRC_USERAGENT'
57+
GO
58+
EXEC sp_addextendedproperty @name = N'MS_Description',
59+
@value = N'the username if available of the person that made the request',
60+
@level0type = N'SCHEMA',
61+
@level0name = N'dbo',
62+
@level1type = N'TABLE',
63+
@level1name = N'TD_API_TRACE',
64+
@level2type = N'COLUMN',
65+
@level2name = N'TRC_USERNAME'
66+
GO
67+
EXEC sp_addextendedproperty @name = N'MS_Description',
68+
@value = N'the type of request e.g. jsonrpc',
69+
@level0type = N'SCHEMA',
70+
@level0name = N'dbo',
71+
@level1type = N'TABLE',
72+
@level1name = N'TD_API_TRACE',
73+
@level2type = N'COLUMN',
74+
@level2name = N'TRC_REQUEST_TYPE'
75+
GO
76+
EXEC sp_addextendedproperty @name = N'MS_Description',
77+
@value = N'the request method e.g. get, post',
78+
@level0type = N'SCHEMA',
79+
@level0name = N'dbo',
80+
@level1type = N'TABLE',
81+
@level1name = N'TD_API_TRACE',
82+
@level2type = N'COLUMN',
83+
@level2name = N'TRC_REQUEST_VERB'
84+
GO
85+
EXEC sp_addextendedproperty @name = N'MS_Description',
86+
@value = N'the path of the url if there is an error',
87+
@level0type = N'SCHEMA',
88+
@level0name = N'dbo',
89+
@level1type = N'TABLE',
90+
@level1name = N'TD_API_TRACE',
91+
@level2type = N'COLUMN',
92+
@level2name = N'TRC_ERROR_PATH'
93+
GO
94+
EXEC sp_addextendedproperty @name = N'MS_Description',
95+
@value = N'the correlation id of the request',
96+
@level0type = N'SCHEMA',
97+
@level0name = N'dbo',
98+
@level1type = N'TABLE',
99+
@level1name = N'TD_API_TRACE',
100+
@level2type = N'COLUMN',
101+
@level2name = N'TRC_CORRELATION_ID'
102+
GO
103+
EXEC sp_addextendedproperty @name = N'MS_Description',
104+
@value = N'JSON RPC error code',
105+
@level0type = N'SCHEMA',
106+
@level0name = N'dbo',
107+
@level1type = N'TABLE',
108+
@level1name = N'TD_API_TRACE',
109+
@level2type = N'COLUMN',
110+
@level2name = N'TRC_JSONRPC_ERROR_CODE'

db/configuration/data script/APPSettings.sql

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ IF NOT EXISTS
240240
(SELECT 1
241241
FROM TS_API_SETTING
242242
where API_KEY = 'API_AD_BLACKLIST_OUS')
243-
INSERT INTO TS_API_SETTING VALUES(@APIID,'API_AD_BLACKLIST_OUS','','List of OU\'s to exclude from AD queries',1);
243+
INSERT INTO TS_API_SETTING VALUES(@APIID,'API_AD_BLACKLIST_OUS','','List of OU\''s to exclude from AD queries',1);
244244

245245
IF NOT EXISTS
246246
(SELECT 1
@@ -306,3 +306,16 @@ FROM TS_API_SETTING
306306
where API_KEY = 'API_TRACE_RECORD_IP')
307307
INSERT INTO TS_API_SETTING VALUES(@APIID,'API_TRACE_RECORD_IP','FALSE','record request ip - Switch on [TRUE] or off [FALSE]',0);
308308

309+
IF NOT EXISTS
310+
(SELECT 1
311+
FROM TS_API_SETTING
312+
where API_KEY = 'API_CACHE_TRACE_ENABLED')
313+
INSERT INTO TS_API_SETTING VALUES(@APIID,'API_CACHE_TRACE_ENABLED','FALSE','TRACE - Switch on [TRUE] or off [FALSE] the api cache trace',0);
314+
315+
316+
317+
IF NOT EXISTS
318+
(SELECT 1
319+
FROM TS_API_SETTING
320+
where API_KEY = 'API_DATABASE_TRACE_ENABLED')
321+
INSERT INTO TS_API_SETTING VALUES(@APIID,'API_DATABASE_TRACE_ENABLED','FALSE','TRACE - Switch on [TRUE] or off [FALSE] the api database trace',0);
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/********************************************************************************
2+
Author Name : Stephen Lane
3+
Date written : 24/10/2023
4+
Version : 1
5+
Description
6+
7+
Records Request information from the API
8+
9+
REVISION HISTORY
10+
----------------
11+
12+
PEER REVIEW HISTORY
13+
-------------------
14+
REVIEW NO. DATE REVIEWED BY COMMENTS
15+
16+
*************************************************************************************/
17+
CREATE PROCEDURE Security_Trace_Create @TrcMethod NVARCHAR(256) = null
18+
,@TrcParams NVARCHAR(2048) = null
19+
,@TrcIp VARCHAR(15) = NULL
20+
,@TrcUseragent VARCHAR(2048)
21+
,@Username NVARCHAR(256) = NULL
22+
,@TrcStartTime datetime
23+
,@TrcDuration decimal(18,3)
24+
,@TrcStatusCode int
25+
,@TrcMachineName varchar(256)
26+
,@TrcErrorPath varchar(1028) = null
27+
,@TrcRequestVerb varchar(50)
28+
,@TrcRequestType varchar(50)
29+
,@TrcCorrelationID varchar(1028)
30+
,@TrcJsonRpcErrorCode int =null
31+
AS
32+
BEGIN
33+
SET NOCOUNT ON;
34+
35+
INSERT INTO TD_API_TRACE (
36+
TRC_METHOD
37+
,TRC_PARAMS
38+
,TRC_IP
39+
,TRC_USERAGENT
40+
,TRC_USERNAME
41+
,TRC_DATETIME
42+
,TRC_STARTTIME
43+
,TRC_DURATION
44+
,TRC_STATUSCODE
45+
,TRC_MACHINENAME
46+
,TRC_REQUEST_TYPE
47+
,TRC_REQUEST_VERB
48+
,TRC_ERROR_PATH
49+
,TRC_CORRELATION_ID
50+
,TRC_JSONRPC_ERROR_CODE)
51+
VALUES (
52+
@TrcMethod
53+
,@TrcParams
54+
,@TrcIp
55+
,@Trcuseragent
56+
,@Username
57+
,getdate()
58+
,@TrcStartTime
59+
,@TrcDuration
60+
,@TrcStatusCode
61+
,@TrcMachineName
62+
,@TrcRequestType
63+
,@TrcRequestVerb
64+
,@TrcErrorPath
65+
,@TrcCorrelationID
66+
,@TrcJsonRpcErrorCode
67+
)
68+
69+
RETURN 1
70+
END
71+
GO
72+
73+

0 commit comments

Comments
 (0)