Skip to content

Conversation

justonian
Copy link

Issue #, if available:
N/A

Description of changes:
Forked existing Node.js and Python blueprints into payload format versions v1 and v2 samples

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Confirmed

* @class AuthPolicy
* @constructor
*/
function AuthPolicy(principal, awsAccountId, apiOptions) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a class -- it only serves to make it confusing. I realize you copy-pasted it, but we really should refactor this out into something clearer (so users read it easier to learn how to make a policy) and simpler (so that it takes less effort to learn).

This could be as simple as a function with this signature.

function createPolicy(principal, awsAccountId, region, stage, apiId, allowedRoutes) {
  // maps through the provided routes and returns a policy that allows only them  
}

}

if (!this.pathRegex.test(resource)) {
throw new Error("Invalid resource path: " + resource + ". Path should match " + this.pathRegex);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test to confirm that it uses route and not routeKey?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants