AWS Cognito用户池和OpenId

时间:2018-05-28 15:17:03

标签: amazon-web-services asp.net-core-mvc asp.net-core-2.0 amazon-cognito

我正在玩Amazon Cognito,在阅读了一些文档并创建用户池后,我遇到了一些问题。我相信Cognito用户池可以与OpenId一起使用,将用户重定向到托管UI以进行用户身份验证(无需联合到其他提供商)。我曾尝试使用DotNetCore 2中的身份验证选项来执行此操作,因为这是我之前与其他提供程序所做的事情。

我有以下内容:

from itertools import starmap
import math
class Point(object):
    def __init__(self,x,y):
        self.x=x
        self.y=y
    def move(self,dx,dy):
        self.x+=dx
        self.y+=dy


class LineString(object):

    def __init__(self,*args): # A method with any number of arguments, args

        self.args=[Point(*args) for p in args] # A list of Points

    def length(self):
        pairs=zip(self.args, self.args[1:])
        return sum(starmap(distance,pairs))

def distance(p1, p2):
    a = p1.x,p1.y
    b = p2.x,p2.y

    print (math.sqrt((a[0]-b[0])**2-(a[1]-b[1])**2))
    # calculates distance between two given points p1 and p2
    return math.sqrt((a** 2)+ (b** 2))


if __name__ == '__main__':
    # Tests for LineString
    # ===================================
    lin1 = LineString((1, 1), (0, 2))

    assert lin1.length() == sqrt(2.0)

    lin1.move(-1, -1) # Move by -1 and -1 for x and y respectively

    assert lin1[0].y == 0 # Inspect the y value of the start point.
    # Implement this by overloading __getitem__(self, key) in your class.

    lin2 = LineString((1, 1), (1, 2), (2, 2))

    assert lin2.length() == 2.0

    lin2.move(-1, -1) # Move by -1 and -1 for x and y respectively

    assert lin2.length() == 2.0

    assert lin2[-1].x == 1 # Inspect the x value of the end point.

    print ('Success! Line tests passed!')

但每次我尝试它总是返回

services.AddAuthentication(options =>
{
    options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
    options.ResponseType = "code";
    options.MetadataAddress = $"https://cognito-idp.{authOptions.AwsRegion}.amazonaws.com/{authOptions.PoolId}/.well-known/openid-configuration";
    options.ClientId = authOptions.ClientId;
    options.ClientSecret = authOptions.ClientSecret;
});

只是想知道是否有人有这方面的经验吗?我试图在不同的地区创建用户池,以确保它不仅在某些地区得到支持,而且总是得到相同的。

1 个答案:

答案 0 :(得分:6)

我曾经遇到过同样的问题。根据{{​​3}}教程配置我的池和代码。关键部分是

  

另一个可能很重要的配置是App集成>域名。它允许我们配置登录和注册页面的域名。

在我配置了domian名称后,一切正常。