Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 7df161f

Browse files
committed
lint and minor fixes
1 parent 3479a2f commit 7df161f

File tree

1 file changed

+54
-70
lines changed
  • content/en/user-guide/aws/verifiedpermissions

1 file changed

+54
-70
lines changed

content/en/user-guide/aws/verifiedpermissions/index.md

Lines changed: 54 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Verified Permissions uses the [Cedar policy language](https://docs.cedarpolicy.c
1313

1414
Verified Permissions provides authorization by verifying whether a principal is allowed to perform an action on a resource in a given context in your application.
1515

16-
LocalStack allows you to use the Verified Permissions APIs in your local environment to test XXXX
16+
LocalStack allows you to use the Verified Permissions APIs in your local environment to test your authorization logic, with integrations with other AWS services like Cognito.
1717
The supported APIs are available on our [API coverage page](https://docs.localstack.cloud/references/coverage/coverage_verifiedpermissions/), which provides information on the extent of Verified Permissions' integration with LocalStack.
1818

1919
{{< alert title="Note">}}
@@ -34,11 +34,13 @@ To create a Verified Permissions Policy Store, use the [`CreatePolicyStore`](htt
3434
Run the following command to create a Policy Store with Schema validation settings set to `OFF`:
3535

3636
{{< command >}}
37-
$ awslocal verifiedpermissions create-policy-store --validation-settings mode=OFF --description "A local Policy Store"
37+
awslocal verifiedpermissions create-policy-store \
38+
--validation-settings mode=OFF \
39+
--description "A local Policy Store"
3840
{{< /command >}}
3941

4042
The above command returns the following response:
41-
XXXXX
43+
4244
```json
4345
{
4446
"policyStoreId": "q5PCScu9qo4aswMVc0owNN",
@@ -52,7 +54,7 @@ You can list all the Verified Permissions policy stores using the [`ListPolicySt
5254
Run the following command to list all the Verified Permissions policy stores:
5355

5456
{{< command >}}
55-
$ awslocal verifiedpermissions list-policy-stores
57+
awslocal verifiedpermissions list-policy-stores
5658
{{< /command >}}
5759

5860
### Create a Policy
@@ -72,15 +74,15 @@ First, create a JSON file containing the following policy named `static_policy.j
7274

7375
You can then run this command to create the policy:
7476
{{< command >}}
75-
$ awslocal verifiedpermissions create-policy \
77+
awslocal verifiedpermissions create-policy \
7678
--definition file://static_policy.json \
7779
--policy-store-id q5PCScu9qo4aswMVc0owNN
7880
{{< /command >}}
7981

82+
Replace the policy store ID with the ID of the policy store you created previously.
8083

81-
Replace the policy store ID with the ID of the policy store you created previously.
84+
You should see the following output:
8285

83-
Should get following output:
8486
```json
8587
{
8688
"policyStoreId": "q5PCScu9qo4aswMVc0owNN",
@@ -112,14 +114,15 @@ We can now make use of the Policy Store and the Policy to start authorizing requ
112114
To authorize a request using Verified Permissions, use the [`IsAuthorized`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_IsAuthorized.html) API.
113115

114116
{{< command >}}
115-
$ awslocal verifiedpermissions is-authorized \
117+
awslocal verifiedpermissions is-authorized \
116118
--policy-store-id q5PCScu9qo4aswMVc0owNN \
117119
--principal entityType=User,entityId=alice \
118120
--action actionType=Action,actionId=view \
119121
--resource entityType=Album,entityId=trip
120122
{{< /command >}}
121123

122124
You should get the following output, indicating that your request was allowed:
125+
123126
```json
124127
{
125128
"decision": "ALLOW",
@@ -132,21 +135,22 @@ You should get the following output, indicating that your request was allowed:
132135
}
133136
```
134137

135-
136138
## Integration with Cognito
137139

138-
Verified Permissions allows you to use external identity provider (IdP) via Idendity Sources.
140+
Verified Permissions allows you to use external identity provider (IdP) via Identity Sources.
139141
Your application can use JSON web tokens (JWTs) generated by your IdP in authorization requests.
140-
The user identity in the token is mapped to the principal ID of the request.
142+
The user identity in the token is mapped to the principal ID of the request.
141143

142-
With ID tokens, Verified Permissions maps attribute claims to principal attributes. With Access tokens, these claims are mapped to context.
144+
With ID tokens, Verified Permissions maps attribute claims to principal attributes.
145+
With Access tokens, these claims are mapped to context.
143146

144147
### Create a Cognito UserPool
145148
To create a user pool, you can use the [`CreateUserPool`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPool.html) API call.
146149
The following command creates a user pool named `avp-test`:
147150

148151
{{< command >}}
149-
$ awslocal cognito-idp create-user-pool --pool-name avp-test
152+
awslocal cognito-idp create-user-pool \
153+
--pool-name avp-test
150154
{{< /command >}}
151155

152156
You can see an output similar to the following:
@@ -156,50 +160,20 @@ You can see an output similar to the following:
156160
"UserPool": {
157161
"Id": "us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
158162
"Name": "avp-test",
159-
"Policies": {
160-
"PasswordPolicy": {
161-
"MinimumLength": 8,
162-
"RequireUppercase": true,
163-
"RequireLowercase": true,
164-
"RequireNumbers": true,
165-
"RequireSymbols": true,
166-
"TemporaryPasswordValidityDays": 7
167-
}
168-
},
169-
"DeletionProtection": "INACTIVE",
170-
"LambdaConfig": {},
163+
"Arn": "arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
171164
"LastModifiedDate": 1745357214.529315,
172165
"CreationDate": 1745357214.529319,
173166
"SchemaAttributes": ["...truncated"],
174167
"VerificationMessageTemplate": {
175168
"DefaultEmailOption": "CONFIRM_WITH_CODE"
176169
},
177-
"UserAttributeUpdateSettings": {
178-
"AttributesRequireVerificationBeforeUpdate": []
179-
},
180170
"MfaConfiguration": "OFF",
181171
"EstimatedNumberOfUsers": 0,
182172
"EmailConfiguration": {
183173
"EmailSendingAccount": "COGNITO_DEFAULT"
184174
},
185-
"AdminCreateUserConfig": {
186-
"AllowAdminCreateUserOnly": false,
187-
"UnusedAccountValidityDays": 7
188-
},
189-
"Arn": "arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
190-
"AccountRecoverySetting": {
191-
"RecoveryMechanisms": [
192-
{
193-
"Priority": 1,
194-
"Name": "verified_email"
195-
},
196-
{
197-
"Priority": 2,
198-
"Name": "verified_phone_number"
199-
}
200-
]
201-
},
202-
"UserPoolTier": "ESSENTIALS"
175+
"UserPoolTier": "ESSENTIALS",
176+
"...": "truncated"
203177
}
204178
}
205179
```
@@ -214,10 +188,13 @@ You can use the [`CreateUserPoolClient`](https://docs.aws.amazon.com/cognito-use
214188
Run the following command, replacing the `--user-pool-id` with the one from the previous step:
215189

216190
{{< command >}}
217-
$ awslocal cognito-idp create-user-pool-client --user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f --client-name avp-client
191+
awslocal cognito-idp create-user-pool-client \
192+
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
193+
--client-name avp-client
218194
{{< /command >}}
219195

220196
You can see an output similar to the following:
197+
221198
```json
222199
{
223200
"UserPoolClient": {
@@ -240,52 +217,54 @@ You will also need the user pool client's `ClientId` for further operations.
240217

241218
### Create a Cognito Group
242219

243-
To use a Verified Permissions policy that validate whether your user is part of a group, we can leverage Cognito Groups.
220+
To use a Verified Permissions policy that validate whether your user is part of a group, we can leverage Cognito Groups.
244221

245222
First, create a group named `AVPGroup`:
246223
{{< command >}}
247-
$ awslocal cognito-idp create-group --user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f --group AVPGroup
224+
awslocal cognito-idp create-group \
225+
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
226+
--group AVPGroup
248227
{{< /command >}}
249228

250229
### Create a Cognito User
251230

252-
You can now create a user, which will be used when sending requests to Verified Permissions.
231+
You can now create a user, which will be used when sending requests to Verified Permissions.
253232
We will use `avp-user` for its username, and `avp@test.com` as its email address.
254233

255234
We can run the 4 following commands to create the user, add it to the Cognito Group then get the Identity Token and Access Token for the user.
256-
You will need to replace the `--user-pool-id` from the User Pool `id` from the first step, and the `--client-id` with the User Pool Client `id` from the step above.
235+
You will need to replace the `--user-pool-id` from the User Pool `id` from the first step, and the `--client-id` with the User Pool Client `id` from the step above.
257236

258237
{{< command >}}
259-
$ awslocal cognito-idp admin-create-user \
238+
awslocal cognito-idp admin-create-user \
260239
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
261240
--username avp-user \
262241
--user-attributes Name=email,Value="avp@test.com" Name=email_verified,Value=true
263242
{{< /command >}}
264243

265244
{{< command >}}
266-
$ awslocal cognito-idp admin-set-user-password \
245+
awslocal cognito-idp admin-set-user-password \
267246
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
268247
--username avp-user \
269248
--password Test123! \
270249
--permanent
271250
{{< /command >}}
272251

273252
{{< command >}}
274-
$ awslocal cognito-idp admin-add-user-to-group \
253+
awslocal cognito-idp admin-add-user-to-group \
275254
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
276255
--username avp-user \
277256
--group-name AVPGroup
278257
{{< /command >}}
279258

280259
{{< command >}}
281-
$ awslocal cognito-idp initiate-auth \
260+
awslocal cognito-idp initiate-auth \
282261
--auth-flow USER_PASSWORD_AUTH \
283262
--client-id xhixnryjv7fcc07s95xau9cjze \
284263
--auth-parameters USERNAME=avp-user,PASSWORD=Test123!
285264
{{< /command >}}
286265

287-
288266
From the last command, you can see an output similar to the following:
267+
289268
```json
290269
{
291270
"ChallengeParameters": {},
@@ -299,13 +278,15 @@ From the last command, you can see an output similar to the following:
299278
}
300279
```
301280

302-
You will need the `IdToken` for the Verified Permissions authorization request.
281+
You will need the `IdToken` for the Verified Permissions authorization request.
303282

304283
### Create a Policy Store
305284

306285
We can now create a new Policy Store:
307286
{{< command >}}
308-
$ awslocal verifiedpermissions create-policy-store --validation-settings mode=OFF --description "Policy Store with Cognito"
287+
awslocal verifiedpermissions create-policy-store \
288+
--validation-settings mode=OFF \
289+
--description "Policy Store with Cognito"
309290
{{< /command >}}
310291

311292
The above command returns the following response:
@@ -319,14 +300,15 @@ The above command returns the following response:
319300
}
320301
```
321302

322-
You will need the `policyStoreId` for the next commands.
303+
You will need the `policyStoreId` for the next commands.
323304

324305
### Create an Identity Source
325306

326307
You can now create an Identity Source, which is a representation of an external identity provider, Cognito in our case.
327308
To create a Verified Permissions Identity Source, use the [`CreateIdentitySource`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_CreateIdentitySource.html) API.
328309

329-
First, create a JSON file containing the following Identity Source configuration named `identity_source.json`. Replace the `userPoolArn` with the User Pool `Arn` value from the previous step, and the `clientIds` value from the User Pool Client `Id`:
310+
First, create a JSON file containing the following Identity Source configuration named `identity_source.json`.
311+
Replace the `userPoolArn` with the User Pool `Arn` value from the previous step, and the `clientIds` value from the User Pool Client `Id`:
330312

331313
```json
332314
{
@@ -339,13 +321,12 @@ First, create a JSON file containing the following Identity Source configuration
339321
```
340322

341323
{{< command >}}
342-
$ awslocal verifiedpermissions create-identity-source \
324+
awslocal verifiedpermissions create-identity-source \
343325
--policy-store-id ESIPIqX1pUHDvwqekZno1G \
344326
--principal-entity-type "User" \
345327
--configuration file://identity_source.json
346328
{{< /command >}}
347329

348-
349330
### Create a Policy
350331

351332
You will now create a Policy that will take advantage of the configuration of your Identity Source, and will provide access to the resource if the principal is part of the group type that was defined in the IdentitySource configuration, and the group identity that was defined in Cognito.
@@ -363,12 +344,13 @@ First, create a JSON file containing the following policy named `policy_cognito.
363344

364345
You can then run this command to create the policy:
365346
{{< command >}}
366-
$ awslocal verifiedpermissions create-policy \
347+
awslocal verifiedpermissions create-policy \
367348
--definition file://policy_cognito.json \
368349
--policy-store-id ESIPIqX1pUHDvwqekZno1G
369350
{{< /command >}}
370351

371352
You should see similiar output:
353+
372354
```json
373355
{
374356
"policyStoreId": "ESIPIqX1pUHDvwqekZno1G",
@@ -396,7 +378,8 @@ You should see similiar output:
396378

397379
### Authorize a request with a Cognito Token
398380

399-
Finally, you can use everything that we created above to authorize your request. By using your user's Identity Token, you can run an authorization request that will authenticate your principal, and automatically use the information that its type is of `UserGroup::`, and the value will be from the token attribute `cognito:groups`.
381+
Finally, you can use everything that we created above to authorize your request.
382+
By using your user's Identity Token, you can run an authorization request that will authenticate your principal, and automatically use the information that its type is of `UserGroup::`, and the value will be from the token attribute `cognito:groups`.
400383

401384
To authorize a request with a token using Verified Permissions, use the [`IsAuthorizedWithToken`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_IsAuthorizedWithToken.html) API.
402385

@@ -411,6 +394,7 @@ awslocal verifiedpermissions is-authorized-with-token \
411394
{{< /command >}}
412395

413396
You should get the following output, indicating that your request was allowed:
397+
414398
```json
415399
{
416400
"decision": "ALLOW",
@@ -427,13 +411,13 @@ You should get the following output, indicating that your request was allowed:
427411
}
428412
```
429413

430-
431-
Additionally, you can have more advanced and complex scenarios using Cognito attributes and claims to provide more context to your authorization request. Your policy can also use those additionals attributes to provide more fine-grained authorization.
414+
Additionally, you can have more advanced and complex scenarios using Cognito attributes and claims to provide more context to your authorization request.
415+
Your policy can also use those additionals attributes to provide more fine-grained authorization.
432416

433417
## Current limitations
434418

435-
No Schema validation when creating a new schema using `PutSchema`, and no Policy validation using said schema when creating policies and template policies.
436-
437-
Only Cognito is supported as an IdentitySource, external OIDC providers are not yet implemented.
419+
LocalStack currently has a few limitations in its emulation capabilities:
438420

439-
The validation around Identity Sources and JWT is not fully yet implemented: the identity source is not validated to have a valid `jwks.json` endpoint, and the issuer and signature of the incoming JWT is not validated.
421+
- No Schema validation when creating a new schema using `PutSchema`, and no Policy validation using said schema when creating policies and template policies.
422+
- Only Cognito is supported as an IdentitySource, external OIDC providers are not yet implemented.
423+
- The validation around Identity Sources and JWT is not fully yet implemented: the identity source is not validated to have a valid `jwks.json` endpoint, and the issuer, signature and expiration of the incoming JWT are not validated.

0 commit comments

Comments
 (0)