@alliander-opensource/aws-jwt-sts 0.2.9 → 0.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alliander-opensource/aws-jwt-sts",
3
- "version": "0.2.9",
3
+ "version": "0.3.0",
4
4
  "author": {
5
5
  "name": "Alliander NV"
6
6
  },
@@ -19,9 +19,9 @@ import { KEYUTIL, KJUR } from 'jsrsasign'
19
19
 
20
20
  const client = new KMSClient({})
21
21
 
22
- const ALIAS_PREVIOUS = 'alias/sts/PREVIOUS'
23
- const ALIAS_CURRENT = 'alias/sts/CURRENT'
24
- const ALIAS_PENDING = 'alias/sts/PENDING'
22
+ const ALIAS_PREVIOUS = process.env.PREVIOUS_KEY!.toString()
23
+ const ALIAS_CURRENT = process.env.CURRENT_KEY!.toString()
24
+ const ALIAS_PENDING = process.env.PENDING_KEY!.toString()
25
25
 
26
26
  const ALIASES: string[] = [
27
27
  ALIAS_PREVIOUS,
package/src/index.sign.ts CHANGED
@@ -8,7 +8,7 @@ import base64url from 'base64url'
8
8
 
9
9
  import { Logger } from '@aws-lambda-powertools/logger'
10
10
 
11
- const KEY_ALIAS_CURRENT = 'alias/sts/CURRENT'
11
+ const KEY_ALIAS_CURRENT = process.env.CURRENT_KEY!.toString()
12
12
  const logger = new Logger()
13
13
 
14
14
  export const handler = async (apiEvent: APIGatewayEvent, context: Context): Promise<APIGatewayProxyResult> => {
package/src/index.ts CHANGED
@@ -111,6 +111,21 @@ export interface AwsJwtStsProps {
111
111
  * Optional custom name for the CloudWatch Alarm monitoring Key Rotation Lambda failures, default: sts-key_rotate_errors_lambda-alarm
112
112
  */
113
113
  readonly alarmNameKeyRotationLambdaFailed?: string
114
+
115
+ /**
116
+ * current kms key name
117
+ */
118
+ readonly currentKeyName?: string
119
+
120
+ /**
121
+ * previous kms key name
122
+ */
123
+ readonly previousKeyName?: string
124
+
125
+ /**
126
+ * pending kms key name
127
+ */
128
+ readonly pendingKeyName?: string
114
129
  }
115
130
 
116
131
  /* eslint-disable no-new */
@@ -208,7 +223,10 @@ export class AwsJwtSts extends Construct {
208
223
  architecture,
209
224
  environment: {
210
225
  S3_BUCKET: oidcbucket.bucketName,
211
- ISSUER: issuer
226
+ ISSUER: issuer,
227
+ CURRENT_KEY: 'alias/' + (props.currentKeyName ?? 'sts/CURRENT'),
228
+ PREVIOUS_KEY: 'alias/' + (props.previousKeyName ?? 'sts/PREVIOUS'),
229
+ PENDING_KEY: 'alias/' + (props.pendingKeyName ?? 'sts/PENDING')
212
230
  }
213
231
  })
214
232
 
@@ -223,7 +241,8 @@ export class AwsJwtSts extends Construct {
223
241
  architecture,
224
242
  environment: {
225
243
  ISSUER: issuer,
226
- DEFAULT_AUDIENCE: props.defaultAudience
244
+ DEFAULT_AUDIENCE: props.defaultAudience,
245
+ CURRENT_KEY: 'alias/' + (props.currentKeyName ?? 'sts/CURRENT')
227
246
  }
228
247
  })
229
248
 
@@ -6,6 +6,13 @@ import { mockClient } from 'aws-sdk-client-mock'
6
6
  import { KMSClient, GetPublicKeyCommand, DescribeKeyCommand } from '@aws-sdk/client-kms'
7
7
  import { S3Client } from '@aws-sdk/client-s3'
8
8
 
9
+ process.env = { // set env vars as they are called on load of the file
10
+ CURRENT_KEY: 'alias/sts/CURRENT',
11
+ PREVIOUS_KEY: 'alias/sts/PREVIOUS',
12
+ PENDING_KEY: 'alias/sts/PENDING'
13
+ }
14
+
15
+ // eslint-disable-next-line import/first
9
16
  import { handler } from '../index.keyrotate'
10
17
 
11
18
  const kmsMock = mockClient(KMSClient)
@@ -14,6 +14,8 @@ import {
14
14
  SignCommand
15
15
  } from '@aws-sdk/client-kms'
16
16
 
17
+ process.env.CURRENT_KEY = 'key-1'// set env var as it is called on load of the file
18
+ // eslint-disable-next-line import/first
17
19
  import { handler } from '../index.sign'
18
20
 
19
21
  const kmsMock = mockClient(KMSClient)