- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的应用程序中使用 AWS Cognito。
在注销时,我正在调用 Logout Endpoint .
但是在注销后,我仍然可以使用旧的刷新 token 生成 id-tokens。
这意味着我的注销端点不再工作。我将 token 保存在我的本地存储中,并且在注销时我正在手动清除存储。
My Question is: How to properly use the logout mechanism of AWS Cognito?
最佳答案
我不确定您使用的是哪个框架,但我使用的是 Angular。不幸的是,有多种使用 AWS Cognito 的方法,并且文档不清楚。这是我的身份验证服务的实现(使用 Angular):
- 注 1 - 使用此登录方法 - 一旦您将用户重定向到注销 url - 本地主机会自动刷新并且 token 被删除。
- 注意 2 - 您也可以通过调用手动执行此操作:this.userPool.getCurrentUser().signOut()
import { Injectable } from '@angular/core'
import { CognitoUserPool, ICognitoUserPoolData, CognitoUser } from 'amazon-cognito-identity-js'
import { CognitoAuth } from 'amazon-cognito-auth-js'
import { Router } from '@angular/router'
const COGNITO_CONFIGS: ICognitoUserPoolData = {
UserPoolId: '{INSERT YOUR USER POOL ID}',
ClientId: '{INSERT YOUR CLIENT ID}',
}
@Injectable()
export class CognitoService {
userPool: CognitoUserPool
constructor(
private router: Router
) {
this.createAuth()
}
createAuth(): void {
// Configuration for Auth instance.
const authData = {
UserPoolId: COGNITO_CONFIGS.UserPoolId,
ClientId: COGNITO_CONFIGS.ClientId,
RedirectUriSignIn : '{INSERT YOUR COGNITO REDIRECT URI}',
RedirectUriSignOut : '{INSERT YOUR COGNITO SIGNOUT URI}',
AppWebDomain : '{INSERT YOUR AMAZON COGNITO DOMAIN}',
TokenScopesArray: ['email']
}
const auth: CognitoAuth = new CognitoAuth(authData)
// Callbacks, you must declare, but can be empty.
auth.userhandler = {
onSuccess: function(result) {
},
onFailure: function(err) {
}
}
// Provide the url and parseCognitoWebResponse handles parsing it for us.
const curUrl = window.location.href
auth.parseCognitoWebResponse(curUrl)
}
/**
* Check's if the user is authenticated - used by the Guard.
*/
authenticated(): CognitoUser | null {
this.userPool = new CognitoUserPool(COGNITO_CONFIGS)
// behind the scene getCurrentUser looks for the user on the local storage.
return this.userPool.getCurrentUser()
}
logout(): void {
this.router.navigate(['/logout'])
}
}
关于logout - 如何使用 Amazon Cognito 注销终端节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51257936/
我正在进行 Twitter 集成。 我不知道如何退出 Twitter。 我正在使用以下代码尝试注销...但它只是删除了 token : try {
我可以使用我的站点和 phpBB3 的集成登录系统登录。我不能 注销...我尝试破坏 session ,或使用 ->logout(); 我登录为: $phpBBusername = $_SES
我目前正在学习 firebase facebook auth,但似乎 firebase 不提供 facebook logout api? 因为我在 firefeed.io 上注销,但它并没有注销 fa
环境 Richfaces 3.3.3 JSF 1.2 站点记录器 要求 用户输入所需的申请地址。 Siteminder 拦截并询问用户名和密码。客户提供凭据。客户使用应用程序并单击注销/退出按钮。应用
我喜欢从 Azure 广告 B2C 中注销我的 Web 应用程序。我尝试了以下示例 https://www.janaks.com.np/azure-ad-identity-provider-in-as
通过使用 here 中的 Fitbit 文档。我已在我的应用程序中成功通过 token 过期时间 expires_in=604800 进行 Fitbit 身份验证。我对如何从登录帐户注销感到困惑。是否
我有一个使用 Oauth 2 与 Facebook 集成的应用程序。 我可以使用 FB 授权并很好地查询他们的 REST 和图形 API,但是当我授权时,一个事件的浏览器 session 是使用 FB
在我的应用程序中,我有一个将 BroadcastReceiver 注册到 onStart() 方法中的服务: public void onStart() { if(something....)
我有一个 div 标签,可以说“mydivTag” 它下面有一个子节点,ID为“childID” 我想删除/取消注册/任何“childID”,然后重新创建具有相同 ID“childID”的不同节点 如
我有一个 asp.net 应用程序,我正在使用 FormsAuthantication。当用户关闭页面时,位于 Global.asax Session_End 中的代码被执行:FormsAuthant
我的应用程序的结构如图所示。 在我的 ProfileViewController(选项卡之一)中,有一个注销按钮。 我想弹出回到 RegisterViewController。 如果用户已经注册,我将
有没有办法注销在 php 中完成的摘要式身份验证。 我试过 unset($_SERVER["PHP_AUTH_DIGEST"]);但它不会要求重新登录。我知道如果我关闭浏览器它就会工作,这是我的功能。
我的问题是捕获用户注销。我的代码是: public function onAuthenticationFailure(Request $request, AuthenticationExceptio
我下面的代码是应用程序的 OnClick 注销方法。目前它所做的只是将用户返回到登录页面,但是如果用户按下 Android 手机上的后退按钮,它会将他们带回到他们刚刚注销的页面,我不希望这样.如何更改
我有一个带有面板的表单,我可以在该面板上动态加载多个用户控件。我处理每个控件的事件。 UserControl userControl1 = LoadControl("control.ascx") as
我正在尝试为我们现有的 laravel 站点(laravel 5.2)的注销功能添加一些逻辑,但它不像登录那样简单。 客户端的现有注销工作正常,但我想要做的就是向我的 Cognito 实例添加一个调用
当前从注册处注销 M3 模型的首选方法是什么? 在我的项目中,我使用 Rascal 来分析大约 100 个大型 Java 程序,而我的 JVM 正在慢慢耗尽内存。我在旧版本的注册表中找到了 unreg
此主题与 Java 中的主题相关,但我找不到 C# 的解决方案。 http://theblasfrompas.blogspot.com/2010/01/closing-obsolete-databas
Slick 用大量的日志消息填满了控制台。我想,就像文档建议的那样,使用 slf4j-nop ,所以日志是关闭的,但是 Akka 需要自己的 slf4j 库。 所以我只剩下 akka-slf4j_2.
如果他空闲 20 分钟,我想提醒用户。所以,创建了一个服务。 它在桌面上运行良好,但在手机中它没有显示,有时如果屏幕在后台停留了几个小时,那么一旦我再次进入页面,注销对话框屏幕就会开始倒计时。 我的意
我是一名优秀的程序员,十分优秀!