@xube/kit-aws-auth-infrastructure 0.0.66 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/api/login.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoginAPI = void 0;
4
+ const kit_aws_auth_1 = require("@xube/kit-aws-auth");
4
5
  const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
6
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
5
7
  const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
6
8
  const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
7
9
  const constructs_1 = require("constructs");
@@ -18,6 +20,14 @@ class LoginAPI extends constructs_1.Construct {
18
20
  props.authAPI.restAPI.root
19
21
  .addResource("login")
20
22
  .addMethod(aws_lambda_1.HttpMethod.POST, new aws_apigateway_1.LambdaIntegration(this.loginFunction));
23
+ const ssmPermission = new aws_iam_1.PolicyStatement({
24
+ actions: [
25
+ "ssm:GetParameter",
26
+ "ssm:GetParameters",
27
+ ],
28
+ resources: [`arn:aws:ssm:eu-west-1:*:/parameter/${kit_aws_auth_1.DEFAULT_USER_POOL_CLIENT_ID_NAME}`],
29
+ });
30
+ this.loginFunction.addToRolePolicy(ssmPermission);
21
31
  }
22
32
  }
23
33
  exports.LoginAPI = LoginAPI;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SignUpAPI = void 0;
4
+ const kit_aws_auth_1 = require("@xube/kit-aws-auth");
4
5
  const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
6
+ const aws_iam_1 = require("aws-cdk-lib/aws-iam");
5
7
  const aws_lambda_1 = require("aws-cdk-lib/aws-lambda");
6
8
  const aws_lambda_nodejs_1 = require("aws-cdk-lib/aws-lambda-nodejs");
7
9
  const constructs_1 = require("constructs");
@@ -18,6 +20,13 @@ class SignUpAPI extends constructs_1.Construct {
18
20
  props.authAPI.restAPI.root
19
21
  .addResource("signup")
20
22
  .addMethod(aws_lambda_1.HttpMethod.POST, new aws_apigateway_1.LambdaIntegration(this.signupFunction));
23
+ const ssmPermission = new aws_iam_1.PolicyStatement({
24
+ actions: ["ssm:GetParameter", "ssm:GetParameters"],
25
+ resources: [
26
+ `arn:aws:ssm:eu-west-1:*:/parameter/${kit_aws_auth_1.DEFAULT_USER_POOL_CLIENT_ID_NAME}`,
27
+ ],
28
+ });
29
+ this.signupFunction.addToRolePolicy(ssmPermission);
21
30
  }
22
31
  }
23
32
  exports.SignUpAPI = SignUpAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xube/kit-aws-auth-infrastructure",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,15 +17,15 @@
17
17
  },
18
18
  "homepage": "https://github.com/XubeLtd/dev-kit#readme",
19
19
  "devDependencies": {
20
- "@xube/kit-build": "^0.0.66"
20
+ "@xube/kit-build": "^0.0.68"
21
21
  },
22
22
  "dependencies": {
23
- "@xube/kit-aws": "^0.0.66",
24
- "@xube/kit-aws-auth": "^0.0.66",
25
- "@xube/kit-aws-hooks": "^0.0.66",
26
- "@xube/kit-aws-infrastructure": "^0.0.66",
27
- "@xube/kit-constants": "^0.0.66",
28
- "@xube/kit-log": "^0.0.66",
23
+ "@xube/kit-aws": "^0.0.68",
24
+ "@xube/kit-aws-auth": "^0.0.68",
25
+ "@xube/kit-aws-hooks": "^0.0.68",
26
+ "@xube/kit-aws-infrastructure": "^0.0.68",
27
+ "@xube/kit-constants": "^0.0.68",
28
+ "@xube/kit-log": "^0.0.68",
29
29
  "aws-cdk-lib": "^2.100.0",
30
30
  "aws-lambda": "^1.0.7",
31
31
  "constructs": "^10.3.0"
package/src/api/login.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { DEFAULT_USER_POOL_CLIENT_ID_NAME } from "@xube/kit-aws-auth";
1
2
  import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
2
- import {
3
- LambdaIntegration,
4
- } from "aws-cdk-lib/aws-apigateway";
3
+ import { LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
4
+ import { PolicyStatement } from "aws-cdk-lib/aws-iam";
5
5
  import { HttpMethod, Runtime } from "aws-cdk-lib/aws-lambda";
6
6
  import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
7
7
  import { Construct } from "constructs";
@@ -15,11 +15,7 @@ export interface LoginAPIProps {
15
15
  export class LoginAPI extends Construct {
16
16
  loginFunction: NodejsFunction;
17
17
 
18
- constructor(
19
- scope: Construct,
20
- id: string,
21
- props: LoginAPIProps
22
- ) {
18
+ constructor(scope: Construct, id: string, props: LoginAPIProps) {
23
19
  super(scope, id);
24
20
 
25
21
  this.loginFunction = new NodejsFunction(scope, id + "-login", {
@@ -31,5 +27,15 @@ export class LoginAPI extends Construct {
31
27
  props.authAPI.restAPI.root
32
28
  .addResource("login")
33
29
  .addMethod(HttpMethod.POST, new LambdaIntegration(this.loginFunction));
30
+
31
+ const ssmPermission = new PolicyStatement({
32
+ actions: [
33
+ "ssm:GetParameter",
34
+ "ssm:GetParameters",
35
+ ],
36
+ resources: [`arn:aws:ssm:eu-west-1:*:/parameter/${DEFAULT_USER_POOL_CLIENT_ID_NAME}`],
37
+ });
38
+
39
+ this.loginFunction.addToRolePolicy(ssmPermission);
34
40
  }
35
41
  }
package/src/api/signup.ts CHANGED
@@ -1,7 +1,7 @@
1
+ import { DEFAULT_USER_POOL_CLIENT_ID_NAME } from "@xube/kit-aws-auth";
1
2
  import { XubeRestAPI } from "@xube/kit-aws-infrastructure";
2
- import {
3
- LambdaIntegration,
4
- } from "aws-cdk-lib/aws-apigateway";
3
+ import { LambdaIntegration } from "aws-cdk-lib/aws-apigateway";
4
+ import { PolicyStatement } from "aws-cdk-lib/aws-iam";
5
5
  import { HttpMethod, Runtime } from "aws-cdk-lib/aws-lambda";
6
6
  import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
7
7
  import { Construct } from "constructs";
@@ -15,11 +15,7 @@ export interface SignUpAPIProps {
15
15
  export class SignUpAPI extends Construct {
16
16
  signupFunction: NodejsFunction;
17
17
 
18
- constructor(
19
- scope: Construct,
20
- id: string,
21
- props: SignUpAPIProps
22
- ) {
18
+ constructor(scope: Construct, id: string, props: SignUpAPIProps) {
23
19
  super(scope, id);
24
20
 
25
21
  this.signupFunction = new NodejsFunction(scope, id + "-signup", {
@@ -31,5 +27,14 @@ export class SignUpAPI extends Construct {
31
27
  props.authAPI.restAPI.root
32
28
  .addResource("signup")
33
29
  .addMethod(HttpMethod.POST, new LambdaIntegration(this.signupFunction));
30
+
31
+ const ssmPermission = new PolicyStatement({
32
+ actions: ["ssm:GetParameter", "ssm:GetParameters"],
33
+ resources: [
34
+ `arn:aws:ssm:eu-west-1:*:/parameter/${DEFAULT_USER_POOL_CLIENT_ID_NAME}`,
35
+ ],
36
+ });
37
+
38
+ this.signupFunction.addToRolePolicy(ssmPermission);
34
39
  }
35
40
  }