Skip to content

v0.10.3

Compare
Choose a tag to compare
@icebob icebob released this 17 Oct 13:49
· 87 commits to master since this release

Named authenticate & authorize methods #275

You can define custom authentication and authorization methods for every routes. In this case you should set the method name instead of true value.

module.exports = {
    mixins: ApiGatewayService,

    settings: {

        routes: [
            {
                path: "/aaa",
                authentication: "aaaAuthn",
                authorization: "aaaAuthz",
                aliases: {
                    "GET hello": "test.hello"
                }
            },
            {
                path: "/bbb",
                authentication: "bbbAuthn",
                authorization: "bbbAuthz",
                aliases: {
                    "GET hello": "test.hello"
                }
            },
            {
                path: "/ccc",
                authentication: true,
                authorization: true,
                aliases: {
                    "GET hello": "test.hello"
                }
            }
        ]
    },

    methods: {
        aaaAuthn() {
            // ... do authn
        },
        aaaAuthz() {
            // ... do authz
        },

        bbbAuthn() {
            // ... do authn
        },
        bbbAuthz() {
            // ... do authz
        },

        authenticate() {
            // ... do authn
        },
        authorize() {
            // ... do authz
        }
    }
}

Configure rate limit options in routes level

module.exports = {
    name: 'api',
    mixins: [ApiGateway],
    settings: {
        rateLimit: rateLimitGlobalConfig,
        routes: [
            {
                path: '/withLocalRateLimit',
                // now you can pass rateLimit here
                // it will override the global rateLimit
                rateLimit: rateLimitConfig,
                aliases: {
                    'GET /2': 'test.2'
                }
            },
            {
                path: '/withGlobalRateLimit',
                aliases: {
                    'GET /1': 'test.1'
                }
            }
        ]
    }
}

Other changes

  • update dependencies.
  • add support for custom cors origin function. #274
  • typescript definition file is rewritten. #259