You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 7, 2025. It is now read-only.
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.
15
15
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.
17
17
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.
18
18
19
19
{{< alert title="Note">}}
@@ -34,11 +34,13 @@ To create a Verified Permissions Policy Store, use the [`CreatePolicyStore`](htt
34
34
Run the following command to create a Policy Store with Schema validation settings set to `OFF`:
35
35
36
36
{{< command >}}
37
-
$ awslocal verifiedpermissions create-policy-store --validation-settings mode=OFF --description "A local Policy Store"
@@ -52,7 +54,7 @@ You can list all the Verified Permissions policy stores using the [`ListPolicySt
52
54
Run the following command to list all the Verified Permissions policy stores:
53
55
54
56
{{< command >}}
55
-
$ awslocal verifiedpermissions list-policy-stores
57
+
awslocal verifiedpermissions list-policy-stores
56
58
{{< /command >}}
57
59
58
60
### Create a Policy
@@ -72,15 +74,15 @@ First, create a JSON file containing the following policy named `static_policy.j
72
74
73
75
You can then run this command to create the policy:
74
76
{{< command >}}
75
-
$ awslocal verifiedpermissions create-policy \
77
+
awslocal verifiedpermissions create-policy \
76
78
--definition file://static_policy.json \
77
79
--policy-store-id q5PCScu9qo4aswMVc0owNN
78
80
{{< /command >}}
79
81
82
+
Replace the policy store ID with the ID of the policy store you created previously.
80
83
81
-
Replace the policy store ID with the ID of the policy store you created previously.
84
+
You should see the following output:
82
85
83
-
Should get following output:
84
86
```json
85
87
{
86
88
"policyStoreId": "q5PCScu9qo4aswMVc0owNN",
@@ -112,14 +114,15 @@ We can now make use of the Policy Store and the Policy to start authorizing requ
112
114
To authorize a request using Verified Permissions, use the [`IsAuthorized`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_IsAuthorized.html) API.
113
115
114
116
{{< command >}}
115
-
$ awslocal verifiedpermissions is-authorized \
117
+
awslocal verifiedpermissions is-authorized \
116
118
--policy-store-id q5PCScu9qo4aswMVc0owNN \
117
119
--principal entityType=User,entityId=alice \
118
120
--action actionType=Action,actionId=view \
119
121
--resource entityType=Album,entityId=trip
120
122
{{< /command >}}
121
123
122
124
You should get the following output, indicating that your request was allowed:
125
+
123
126
```json
124
127
{
125
128
"decision": "ALLOW",
@@ -132,21 +135,22 @@ You should get the following output, indicating that your request was allowed:
132
135
}
133
136
```
134
137
135
-
136
138
## Integration with Cognito
137
139
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.
139
141
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.
141
143
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.
143
146
144
147
### Create a Cognito UserPool
145
148
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.
146
149
The following command creates a user pool named `avp-test`:
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.
253
232
We will use `avp-user` for its username, and `avp@test.com` as its email address.
254
233
255
234
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.
@@ -319,14 +300,15 @@ The above command returns the following response:
319
300
}
320
301
```
321
302
322
-
You will need the `policyStoreId` for the next commands.
303
+
You will need the `policyStoreId` for the next commands.
323
304
324
305
### Create an Identity Source
325
306
326
307
You can now create an Identity Source, which is a representation of an external identity provider, Cognito in our case.
327
308
To create a Verified Permissions Identity Source, use the [`CreateIdentitySource`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_CreateIdentitySource.html) API.
328
309
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`:
330
312
331
313
```json
332
314
{
@@ -339,13 +321,12 @@ First, create a JSON file containing the following Identity Source configuration
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.
363
344
364
345
You can then run this command to create the policy:
365
346
{{< command >}}
366
-
$ awslocal verifiedpermissions create-policy \
347
+
awslocal verifiedpermissions create-policy \
367
348
--definition file://policy_cognito.json \
368
349
--policy-store-id ESIPIqX1pUHDvwqekZno1G
369
350
{{< /command >}}
370
351
371
352
You should see similiar output:
353
+
372
354
```json
373
355
{
374
356
"policyStoreId": "ESIPIqX1pUHDvwqekZno1G",
@@ -396,7 +378,8 @@ You should see similiar output:
396
378
397
379
### Authorize a request with a Cognito Token
398
380
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`.
400
383
401
384
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.
You should get the following output, indicating that your request was allowed:
397
+
414
398
```json
415
399
{
416
400
"decision": "ALLOW",
@@ -427,13 +411,13 @@ You should get the following output, indicating that your request was allowed:
427
411
}
428
412
```
429
413
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.
432
416
433
417
## Current limitations
434
418
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:
438
420
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