Skip to content

Demo of using Amazon's Cognito service in the browser, using a Rails project

Notifications You must be signed in to change notification settings

step1profit/CognitoTest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cognito Demo

Using code sampled from Amazon Cognito js

This demo currently only shows an unauthenticated user connecting to my AWS account.

In order to get Cognito working correctly, it's important to define your account's unauthenticated user role very precisely, making sure that the trust relationship between it and entities that can assume this role are very well defined.

A sample trust policy for an unauthenticated user is:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Federated": "cognito-identity.amazonaws.com"
      },
      "Action": "sts:AssumeRoleWithWebIdentity",
      "Condition": {
        "StringEquals": {
          "cognito-identity.amazonaws.com:aud": "YOUR_IDENTITY_POOL_ID"
        },
        "ForAnyValue:StringLike": {
          "cognito-identity.amazonaws.com:amr": "unauthenticated"
        }
      }
    }
  ]
}

Permissions must be granted as well. This is a sample permission policy for an unauthenticated user (though it can be more conservative):

{
    "Version": "2012-10-17",
    "Statement": [{
        "Action": [
            "mobileanalytics:PutEvents",
            "cognito-identity:*",
            "cognito-sync:*",
            "sts:*"
        ],
        "Effect": "Allow",
        "Resource": [
            "*"
        ]
    }]
}

These resources were helpful in getting me to understand the service better, and how to implement this successfully:

About

Demo of using Amazon's Cognito service in the browser, using a Rails project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 78.1%
  • JavaScript 17.5%
  • CSS 3.5%
  • CoffeeScript 0.9%