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

Commit a2a44e2

Browse files
committed
remove Cognito integration part
1 parent ce13668 commit a2a44e2

File tree

1 file changed

+0
-279
lines changed
  • content/en/user-guide/aws/verifiedpermissions

1 file changed

+0
-279
lines changed

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

Lines changed: 0 additions & 279 deletions
Original file line numberDiff line numberDiff line change
@@ -133,285 +133,6 @@ You should get the following output, indicating that your request was allowed:
133133
}
134134
```
135135

136-
## Integration with Cognito
137-
138-
Verified Permissions allows you to use external identity provider (IdP) via Identity Sources.
139-
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.
141-
142-
With ID tokens, Verified Permissions maps attribute claims to principal attributes.
143-
With Access tokens, these claims are mapped to context.
144-
145-
### Create a Cognito UserPool
146-
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.
147-
The following command creates a user pool named `avp-test`:
148-
149-
{{< command >}}
150-
$ awslocal cognito-idp create-user-pool \
151-
--pool-name avp-test
152-
{{< /command >}}
153-
154-
You can see an output similar to the following:
155-
156-
```json
157-
{
158-
"UserPool": {
159-
"Id": "us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
160-
"Name": "avp-test",
161-
"Arn": "arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
162-
"LastModifiedDate": 1745357214.529315,
163-
"CreationDate": 1745357214.529319,
164-
"SchemaAttributes": ["...truncated"],
165-
"VerificationMessageTemplate": {
166-
"DefaultEmailOption": "CONFIRM_WITH_CODE"
167-
},
168-
"MfaConfiguration": "OFF",
169-
"EstimatedNumberOfUsers": 0,
170-
"EmailConfiguration": {
171-
"EmailSendingAccount": "COGNITO_DEFAULT"
172-
},
173-
"UserPoolTier": "ESSENTIALS",
174-
"...": "truncated"
175-
}
176-
}
177-
```
178-
179-
You will need the user pool's `Id` and `Arn` for further operations.
180-
181-
### Create a User Pool Client
182-
183-
You can proceed with adding a client to the pool we just created.
184-
You will require the ID of the newly created client for the subsequent steps.
185-
You can use the [`CreateUserPoolClient`](https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolClient.html) for both client creation and extraction of the corresponding ID.
186-
Run the following command, replacing the `--user-pool-id` with the one from the previous step:
187-
188-
{{< command >}}
189-
$ awslocal cognito-idp create-user-pool-client \
190-
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
191-
--client-name avp-client
192-
{{< /command >}}
193-
194-
You can see an output similar to the following:
195-
196-
```json
197-
{
198-
"UserPoolClient": {
199-
"UserPoolId": "us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
200-
"ClientName": "avp-client",
201-
"ClientId": "xhixnryjv7fcc07s95xau9cjze",
202-
"LastModifiedDate": 1745357329.211135,
203-
"CreationDate": 1745357329.211147,
204-
"RefreshTokenValidity": 30,
205-
"TokenValidityUnits": {},
206-
"AllowedOAuthFlowsUserPoolClient": false,
207-
"EnableTokenRevocation": true,
208-
"EnablePropagateAdditionalUserContextData": false,
209-
"AuthSessionValidity": 3
210-
}
211-
}
212-
```
213-
214-
You will also need the user pool client's `ClientId` for further operations.
215-
216-
### Create a Cognito Group
217-
218-
To use a Verified Permissions policy that validate whether your user is part of a group, we can leverage Cognito Groups.
219-
220-
First, create a group named `AVPGroup`:
221-
{{< command >}}
222-
$ awslocal cognito-idp create-group \
223-
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
224-
--group AVPGroup
225-
{{< /command >}}
226-
227-
### Create a Cognito User
228-
229-
You can now create a user, which will be used when sending requests to Verified Permissions.
230-
We will use `avp-user` for its username, and `avp@test.com` as its email address.
231-
232-
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.
233-
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.
234-
235-
{{< command >}}
236-
$ awslocal cognito-idp admin-create-user \
237-
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
238-
--username avp-user \
239-
--user-attributes Name=email,Value="avp@test.com" Name=email_verified,Value=true
240-
{{< /command >}}
241-
242-
{{< command >}}
243-
$ awslocal cognito-idp admin-set-user-password \
244-
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
245-
--username avp-user \
246-
--password Test123! \
247-
--permanent
248-
{{< /command >}}
249-
250-
{{< command >}}
251-
$ awslocal cognito-idp admin-add-user-to-group \
252-
--user-pool-id us-east-1_84e2d3fb5af24aba9827b82a6971b17f \
253-
--username avp-user \
254-
--group-name AVPGroup
255-
{{< /command >}}
256-
257-
{{< command >}}
258-
$ awslocal cognito-idp initiate-auth \
259-
--auth-flow USER_PASSWORD_AUTH \
260-
--client-id xhixnryjv7fcc07s95xau9cjze \
261-
--auth-parameters USERNAME=avp-user,PASSWORD=Test123!
262-
{{< /command >}}
263-
264-
From the last command, you can see an output similar to the following:
265-
266-
```json
267-
{
268-
"ChallengeParameters": {},
269-
"AuthenticationResult": {
270-
"AccessToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjUyNmMzMjlkLWQ4OWUtNGM0NC1hN2VkLWQ3YTZkNzcwNzNmZCIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDUzNTQxNDMsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3QubG9jYWxzdGFjay5jbG91ZDo0NTY2L3VzLWVhc3QtMV84NGUyZDNmYjVhZjI0YWJhOTgyN2I4MmE2OTcxYjE3ZiIsInN1YiI6IjNhYjllODE2LTgwYWMtNDdlYS1iZDVmLTllMjlmOTc2NzNjZSIsImF1dGhfdGltZSI6MTc0NTM1MDU0MywiaWF0IjoxNzQ1MzUwNTQzLCJldmVudF9pZCI6ImU4Yjg5Yzg2LTdkMGMtNDdhYS1hZTM3LWNjZjEwZDc4M2JiNiIsInRva2VuX3VzZSI6ImFjY2V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ZTM3LWNjZjEwZDc4M2JiNiIsInRva2VuX3VzZSI6ImlkIiwiY29nbml0bzp1c2VybmFtZSI6ImF2cC11c2VyIiwiZW1haWwiOiJhdnBAdGVzdC5jb20iLCJhdWQiOiJ4aGl4bnJ5anY3ZmNjMDdzOTV4YXU5Y2p6ZSIsImNvZ25pdG86Z3JvdXBzIjpbIkFWUEdyb3VwIl0sImVtYWlsX3ZlcmlmaWVkIjoidHJ1ZSIsImNvZ25pdG86dXNlcl9zdGF0dXMiOiJDT05GSVJNRUQifQ.C1tPAu7K7ZBfG5kZtoNRFiTPi3XUG4znTSFLiuSx72CUOe4SIVUkK3fIJ8pg2-CzlbUWKCczRwom2XzLjJkbmYPT3yd6sf3fuQldVS9HFBpYx42v3h23UUz_sccUPpXzuL1sNYzJmoJ_XyVpKBSdCtXYatKbV6o_beZmcQ6GFPTa5iNfAXeozEpjcWl-mHsd3nXVvTr5SrB8dofPfWGGEqYXYwCSBNnb5hXqON1-uwVe2JvyoRQCiqphtxVdjlRn1BYKfwlDm7EWU5-6CPWzqGfnKUrGaacdrYE6UUL5Q0AhA4MuULl0pwk6unzUHJ9SxKipWYdKd8nsx3k4qFSw8Q"
275-
}
276-
}
277-
```
278-
279-
You will need the `IdToken` for the Verified Permissions authorization request.
280-
281-
### Create a Policy Store
282-
283-
We can now create a new Policy Store:
284-
{{< command >}}
285-
$ awslocal verifiedpermissions create-policy-store \
286-
--validation-settings mode=OFF \
287-
--description "Policy Store with Cognito"
288-
{{< /command >}}
289-
290-
The above command returns the following response:
291-
292-
```json
293-
{
294-
"policyStoreId": "ESIPIqX1pUHDvwqekZno1G",
295-
"arn": "arn:aws:verifiedpermissions::000000000000:policy-store/ESIPIqX1pUHDvwqekZno1G",
296-
"createdDate": "2025-04-22T19:37:00.762622Z",
297-
"lastUpdatedDate": "2025-04-22T19:37:00.762622Z"
298-
}
299-
```
300-
301-
You will need the `policyStoreId` for the next commands.
302-
303-
### Create an Identity Source
304-
305-
You can now create an Identity Source, which is a representation of an external identity provider, Cognito in our case.
306-
To create a Verified Permissions Identity Source, use the [`CreateIdentitySource`](https://docs.aws.amazon.com/verifiedpermissions/latest/apireference/API_CreateIdentitySource.html) API.
307-
308-
First, create a JSON file containing the following Identity Source configuration named `identity_source.json`.
309-
Replace the `userPoolArn` with the User Pool `Arn` value from the previous step, and the `clientIds` value from the User Pool Client `Id`:
310-
311-
```json
312-
{
313-
"cognitoUserPoolConfiguration": {
314-
"userPoolArn": "arn:aws:cognito-idp:us-east-1:000000000000:userpool/us-east-1_84e2d3fb5af24aba9827b82a6971b17f",
315-
"clientIds":["xhixnryjv7fcc07s95xau9cjze"],
316-
"groupConfiguration": {"groupEntityType": "UserGroup"}
317-
}
318-
}
319-
```
320-
321-
{{< command >}}
322-
$ awslocal verifiedpermissions create-identity-source \
323-
--policy-store-id ESIPIqX1pUHDvwqekZno1G \
324-
--principal-entity-type "User" \
325-
--configuration file://identity_source.json
326-
{{< /command >}}
327-
328-
### Create a Policy
329-
330-
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.
331-
332-
First, create a JSON file containing the following policy named `policy_cognito.json`:
333-
334-
```json
335-
{
336-
"static": {
337-
"description": "Grant any User that is part of the UserGroup `` access to view the trip Album",
338-
"statement": "permit(principal in UserGroup::\"AVPGroup\", action == Action::\"create\", resource == Album::\"vacations\");"
339-
}
340-
}
341-
```
342-
343-
You can then run this command to create the policy:
344-
{{< command >}}
345-
$ awslocal verifiedpermissions create-policy \
346-
--definition file://policy_cognito.json \
347-
--policy-store-id ESIPIqX1pUHDvwqekZno1G
348-
{{< /command >}}
349-
350-
You should see similiar output:
351-
352-
```json
353-
{
354-
"policyStoreId": "ESIPIqX1pUHDvwqekZno1G",
355-
"policyId": "cF8X6thXBt5uCANQ8GAEK2",
356-
"policyType": "STATIC",
357-
"principal": {
358-
"entityType": "UserGroup",
359-
"entityId": "AVPGroup"
360-
},
361-
"resource": {
362-
"entityType": "Album",
363-
"entityId": "vacations"
364-
},
365-
"actions": [
366-
{
367-
"actionType": "Action",
368-
"actionId": "create"
369-
}
370-
],
371-
"createdDate": "2025-04-22T19:39:54.542438Z",
372-
"lastUpdatedDate": "2025-04-22T19:39:54.542438Z",
373-
"effect": "Permit"
374-
}
375-
```
376-
377-
### Authorize a request with a Cognito Token
378-
379-
Finally, you can use everything that we created above to authorize your request.
380-
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-
382-
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.
383-
384-
You can run the following command to verify that you can authorize the request:
385-
386-
{{< command >}}
387-
$ awslocal verifiedpermissions is-authorized-with-token \
388-
--policy-store-id ESIPIqX1pUHDvwqekZno1G \
389-
--action actionType=Action,actionId=create \
390-
--resource entityType=Album,entityId=vacations \
391-
--identity-token eyJhbGciOiJSUzI1NiIsImtpZCI6IjUyNmMzMjlkLWQ4OWUtNGM0NC1hN2VkLWQ3YTZkNzcwNzNmZCIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NDUzNTQxNDMsImlzcyI6Imh0dHA6Ly9sb2NhbGhvc3QubG9jYWxzdGFjay5jbG91ZDo0NTY2L3VzLWVhc3QtMV84NGUyZDNmYjVhZjI0YWJhOTgyN2I4MmE2OTcxYjE3ZiIsInN1YiI6IjNhYjllODE2LTgwYWMtNDdlYS1iZDVmLTllMjlmOTc2NzNjZSIsImF1dGhfdGltZSI6MTc0NTM1MDU0MywiaWF0IjoxNzQ1MzUwNTQzLCJldmVudF9pZCI6ImU4Yjg5Yzg2LTdkMGMtNDdhYS1hZTM3LWNjZjEwZDc4M2JiNiIsInRva2VuX3VzZSI6ImlkIiwiY29nbml0bzp1c2VybmFtZSI6ImF2cC11c2VyIiwiZW1haWwiOiJhdnBAdGVzdC5jb20iLCJhdWQiOiJ4aGl4bnJ5anY3ZmNjMDdzOTV4YXU5Y2p6ZSIsImNvZ25pdG86Z3JvdXBzIjpbIkFWUEdyb3VwIl0sImVtYWlsX3ZlcmlmaWVkIjoidHJ1ZSIsImNvZ25pdG86dXNlcl9zdGF0dXMiOiJDT05GSVJNRUQifQ.C1tPAu7K7ZBfG5kZtoNRFiTPi3XUG4znTSFLiuSx72CUOe4SIVUkK3fIJ8pg2-CzlbUWKCczRwom2XzLjJkbmYPT3yd6sf3fuQldVS9HFBpYx42v3h23UUz_sccUPpXzuL1sNYzJmoJ_XyVpKBSdCtXYatKbV6o_beZmcQ6GFPTa5iNfAXeozEpjcWl-mHsd3nXVvTr5SrB8dofPfWGGEqYXYwCSBNnb5hXqON1-uwVe2JvyoRQCiqphtxVdjlRn1BYKfwlDm7EWU5-6CPWzqGfnKUrGaacdrYE6UUL5Q0AhA4MuULl0pwk6unzUHJ9SxKipWYdKd8nsx3k4qFSw8Q
392-
{{< /command >}}
393-
394-
You should get the following output, indicating that your request was allowed:
395-
396-
```json
397-
{
398-
"decision": "ALLOW",
399-
"determiningPolicies": [
400-
{
401-
"policyId": "cF8X6thXBt5uCANQ8GAEK2"
402-
}
403-
],
404-
"errors": [],
405-
"principal": {
406-
"entityType": "User",
407-
"entityId": "us-east-1_84e2d3fb5af24aba9827b82a6971b17f|3ab9e816-80ac-47ea-bd5f-9e29f97673ce"
408-
}
409-
}
410-
```
411-
412-
Additionally, you can have more advanced and complex scenarios using Cognito attributes and claims to provide more context to your authorization request.
413-
Your policy can also use those additionals attributes to provide more fine-grained authorization.
414-
415136
## Current limitations
416137

417138
- No Schema validation when creating a new schema using `PutSchema`, and no Policy validation using said schema when creating policies and template policies.

0 commit comments

Comments
 (0)