我有一个支持 Cognito 未验证身份的 JavaScript Web 应用程序。我正在尝试找出如何为 DISABLED 未经身份验证的 IdentityId 识别链接的经过身份验证的 IdentityId。
首先,未经身份验证的用户会通过 AWS.config.credentials.get 获得一个 IdentityId。 CognitoIdentityCredentials 在内部使用 getId生成一个新的未经身份验证的 IdentityId。
let unathenticatedIdentityId;
const AWS = require('aws-sdk');
AWS.config.region = region;
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId
});
AWS.config.credentials.get(err => {
unathenticatedIdentityId = AWS.config.credentials.identityId;
});
然后,我们的用户通过 amazon-cognito-identity-js 向 Cognito 用户池进行身份验证,未经身份验证的 IdentityId 更改为与其 Cognito 登录关联的经过身份验证的 IdentityId。未经身份验证的 IdentityId 会自动标记为 DISABLED 并在内部链接到经过身份验证的 IdentityId。
let authenticatedIdentityId;
const { CognitoUserPool, CognitoUser, AuthenticationDetails } = require('amazon-cognito-identity-js');
const Pool = new CognitoUserPool({
UserPoolId,
ClientId,
});
const authDetails = new AuthenticationDetails({
Username,
Password,
});
const user = new CognitoUser({
Pool,
Username,
});
user.authenticateUser(authDetails, {
onSuccess: (session) => {
AWS.config.credentials.params.Logins = {
[PoolProviderName]: session.idToken.jwtToken,
};
AWS.config.credentials.expired = true;
AWS.config.credentials.refresh(err => {
authenticatedIdentityId = AWS.config.credentials.identityId;
});
},
});
我有 unathenticatedIdentityId 和 authenticatedIdentityId 的值,但我没有在 AWS Cognito API 中看到解决 DISABLED unauthenticatedIdentityId 已链接到 authenticatedIdentityId。相反,我看不到一种方法来识别哪些 IdentityId 已链接到 authenticatedIdentityId。 describeIdentity API 会告诉我 unauthenticatedIdentityId 是 DISABLED 并且它没有 Logins,但它不指向链接的 authenticatedIdentityId.
如何仅链接/禁用 unauthenticatedIdentityId 的值,解析值 authenticatedIdentityId?
最佳答案
我有一个应用程序使用 AWS Cognito 获取身份 ID,然后可能对其进行身份验证。情况是客户端首先以未经身份验证(访客)的身份使用该应用程序,然后使用 Facebook 登录,使他/她自己成为经过身份验证的用户,AWS 会为经过身份验证的用户保留给定的身份 ID,因为他是新用户。现在,问题来了,当您注销该应用程序时,其他人想以未经身份验证甚至经过身份验证的方式使用该应用程序。 Cognito 会错误地指出访问身份 ID 是被禁止的,因为它已经链接到之前用户的 Facebook 帐户。
Cognito 移动 SDK 内置了一种方法来处理此问题。他们在使用身份 ID 时缓存它,这导致了您所看到的问题。当您注销时,您需要清除该缓存。我不确定您使用的是哪个 SDK,但在 iOS 中是 AWSCognitoIdentityProvider.clear() ,在 Android 中是 CognitoCachingCredentialsProvider.clear()。同样,如果您使用的是 Cognito Sync,则该客户端中有一种方法可以删除缓存的 ID 和同步数据。
另请查看 https://aws.amazon.com/blogs/mobile/understanding-amazon-cognito-authentication/
希望您也关注https://aws.amazon.com/blogs/mobile/using-the-amazon-cognito-credentials-provider/
关于javascript - 使用 AWS Cognito 是否可以在给定禁用的未经身份验证的 IdentityId 的情况下解析经过身份验证的 IdentityId?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46044598/
我有一个字符串input="maybe(thisis|thatwas)some((nice|ugly)(day|night)|(strange(weather|time)))"Ruby中解析该字符串的最佳方法是什么?我的意思是脚本应该能够像这样构建句子:maybethisissomeuglynightmaybethatwassomenicenightmaybethiswassomestrangetime等等,你明白了......我应该一个字符一个字符地读取字符串并构建一个带有堆栈的状态机来存储括号值以供以后计算,还是有更好的方法?也许为此目的准备了一个开箱即用的库?
给定这段代码defcreate@upgrades=User.update_all(["role=?","upgraded"],:id=>params[:upgrade])redirect_toadmin_upgrades_path,:notice=>"Successfullyupgradeduser."end我如何在该操作中实际验证它们是否已保存或未重定向到适当的页面和消息? 最佳答案 在Rails3中,update_all不返回任何有意义的信息,除了已更新的记录数(这可能取决于您的DBMS是否返回该信息)。http://ar.ru
我想安装一个带有一些身份验证的私有(private)Rubygem服务器。我希望能够使用公共(public)Ubuntu服务器托管内部gem。我读到了http://docs.rubygems.org/read/chapter/18.但是那个没有身份验证-如我所见。然后我读到了https://github.com/cwninja/geminabox.但是当我使用基本身份验证(他们在他们的Wiki中有)时,它会提示从我的服务器获取源。所以。如何制作带有身份验证的私有(private)Rubygem服务器?这是不可能的吗?谢谢。编辑:Geminabox问题。我尝试“捆绑”以安装新的gem..
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
我正在使用ruby1.9解析以下带有MacRoman字符的csv文件#encoding:ISO-8859-1#csv_parse.csvName,main-dialogue"Marceu","Giveittohimóhe,hiswife."我做了以下解析。require'csv'input_string=File.read("../csv_parse.rb").force_encoding("ISO-8859-1").encode("UTF-8")#=>"Name,main-dialogue\r\n\"Marceu\",\"Giveittohim\x97he,hiswife.\"\
我希望我的UserPrice模型的属性在它们为空或不验证数值时默认为0。这些属性是tax_rate、shipping_cost和price。classCreateUserPrices8,:scale=>2t.decimal:tax_rate,:precision=>8,:scale=>2t.decimal:shipping_cost,:precision=>8,:scale=>2endendend起初,我将所有3列的:default=>0放在表格中,但我不想要这样,因为它已经填充了字段,我想使用占位符。这是我的UserPrice模型:classUserPrice回答before_val
这是在Ruby中设置默认值的常用方法:classQuietByDefaultdefinitialize(opts={})@verbose=opts[:verbose]endend这是一个容易落入的陷阱:classVerboseNoMatterWhatdefinitialize(opts={})@verbose=opts[:verbose]||trueendend正确的做法是:classVerboseByDefaultdefinitialize(opts={})@verbose=opts.include?(:verbose)?opts[:verbose]:trueendend编写Verb
我有一个表单,其中有很多字段取自数组(而不是模型或对象)。我如何验证这些字段的存在?solve_problem_pathdo|f|%>... 最佳答案 创建一个简单的类来包装请求参数并使用ActiveModel::Validations。#definedsomewhere,atthesimplest:require'ostruct'classSolvetrue#youcouldevencheckthesolutionwithavalidatorvalidatedoerrors.add(:base,"WRONG!!!")unlesss
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
我有一些非常大的模型,我必须将它们迁移到最新版本的Rails。这些模型有相当多的验证(User有大约50个验证)。是否可以将所有这些验证移动到另一个文件中?说app/models/validations/user_validations.rb。如果可以,有人可以提供示例吗? 最佳答案 您可以为此使用关注点:#app/models/validations/user_validations.rbrequire'active_support/concern'moduleUserValidationsextendActiveSupport: