Skip to content

Releases: denlap007/hapi-audit-rest

Release 4.6.0

23 Nov 10:54
Compare
Choose a tag to compare

Added allowInternals: true for injected requests, allows access to routes with options.isInternal set to true.

Release 4.5.0

25 Apr 13:07
Compare
Choose a tag to compare

Improve error handling of injected requests to be processed by one standard handler.

Release 4.4.0

25 Apr 13:07
Compare
Choose a tag to compare

Improve handling on internal injected GET requests and response parsing. On application json try to parse response payload, if not possible fallback to result.

Release 4.3.0

20 Apr 14:25
Compare
Choose a tag to compare

Due to a problem, 4.2.0 was unpublished from npm registry. The fixed new release was published again as 4.3.0.

Release 4.2.0

20 Apr 13:43
Compare
Choose a tag to compare

Separated cache logic from audit. Added response caching of any GET request with path params, even if auditing of GET requests is disabled by the user. Previously, the request would be cached only if it could be audited.

Release 4.1.0

19 Apr 07:55
Compare
Choose a tag to compare

Added isAuditable function on routeOptions, invoked with one parameter, the current request.

Release 4.0.1

18 Apr 13:32
Compare
Choose a tag to compare

fix to set request payload as default source of auditing data on POST 204 with empty string response

Release 4.0.0

26 Dec 15:43
1ef7a7e
Compare
Choose a tag to compare

Breaking changes v4

Node.js

Dropped support for Node.js 12. Minimum Node.js version is now 14

API changes

Registration Options

  • auditAuthOnly -> removed (can be filtered with isAuditable, check example below)
  • auditGetRequests -> removed (can be filtered with isAuditable, check example below)
  • showErrorsOnStdErr -> renamed to debug (false by default)
  • isAuditable -> invoked with request as parameter (arity 1) to handle all cases (audits all by default, check example below for filtering)
  • getEntity -> renamed to setEntity. Returns by default the endpoint path
  • cacheEnabled -> renamed to isCacheEnabled

Example using isAuditable (auditAuthOnly, auditGetRequests cases and path filtering)

await server.register({
    plugin: require("hapi-audit-rest"),
    options: {
        isAuditable: ({ auth: { isAuthenticated }, method, url: { pathname } }) => {
            // do not audit unauthenticated requests
            if (!isAuthenticated) {
                return false
            }
            
            // do not audit GET requests
            if (method === "get") {
                return false
            }
            
            // do not audit requests when path does not start from /api
            if (!pathname.startsWith("/api")) {
                return false
            }
            
            // return true to audit all other cases
            return true
        }
    },
});

Example using setEntity option:

await server.register({
    plugin: require("hapi-audit-rest"),
    options: {
        // use the standard pattern of an api i.e. /api/v1.0/users, to refine the entity name
        // will have 'entity: users' in audit log
        setEntity: (path) => path.split("/")[3], 
        }
    },
});

Route Options

  • getPath -> renamed to setInjectedPath

Release 3.5.2

04 Dec 19:23
Compare
Choose a tag to compare
v3.5.2

Merge branch 'master' of https://github.com/denlap007/hapi-audit-rest

Release 3.5.1

03 Oct 19:11
Compare
Choose a tag to compare
v3.5.1

packages and version