Giter Club home page Giter Club logo

aspnetcore.identity.dynamodb's Introduction

AspNetCore.Identity.DynamoDB

Travis Build Status AppVeyor Build Status NuGet package version

DynamoDB data store adaptor for ASP.NET Core Identity, which allows you to build ASP.NET Core web applications, including membership, login, and user data.With this library, you can store your user's membership related data on DynamoDB.

Using the Library

The library is available at NuGet.org. You can start using the library by integrating it into your project.json file. This library supports netstandard1.6.

Samples

You can find some samples under ./samples folder and each of the sample contain a README file on its own with the instructions showing how to run them.

Tests

In order to be able to run the tests, you need to have DynamoDB up and running on localhost:8000. You can easily do this by running the below Docker command:

docker run -p 8000:8000 dwmkerr/dynamodb -sharedDb -inMemory

After that, you can run the tests through your preferred test runner (e.g. JetBrains Rider test runner) or by invoking the dotnet test command under the test project directory.

Notes

The project is based on awesome work of @tugberkugurlu who created MongoDB adaptor to AspNetCore, rewritten and adapted to the specifics of DynamoDB.

License

The MIT License (MIT)

Copyright (c) 2016 Tugberk Ugurlu
Copyright (c) 2017 Vasiliy Solovey

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

aspnetcore.identity.dynamodb's People

Contributors

cmsd2 avatar frmokoena avatar mattwhetton avatar miltador avatar sorenz avatar tugberkugurlu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

aspnetcore.identity.dynamodb's Issues

Update for Identity 2 ?

Are there any plans to update this for Identity 2 ? I cant get it to compile in a .net 2 app using Identity 2. Mostly errors like : The type or namespace name 'Claim' could not be found.

Identity Options does not contain a definition for "Cookies"

Hello,

This is a great project. However, it seems that IdentityOptions have move on and no longer have the Cookies extension.

Any thoughts on how to solve this?


var id = new ClaimsIdentity(Options.Cookies.ApplicationCookieAuthenticationScheme,
                    Options.ClaimsIdentity.UserNameClaimType,
                    Options.ClaimsIdentity.RoleClaimType);

Regards,

Daniel

Table initialization fails if there are more than 100 tables.

UserStore, RoleStore, and RoleUserStore initialization can fail if there are more than 100 dynamoDb tables in an AWS account. The ListTablesAsync() method that is ran in the EnsureInitializedAsync() methods returns paged results (100 per page), but this library only takes the first page. Since that method is used to determine if a table already exists, it will sometimes think the table does not exist when it actually does. The table is then attempted to be created but results in an error as it's already there.

This can be fixed by simply running through all the pages of the ListTablesAsync() result before checking to see if the table exists or not.

RoleManager.CreateAsync calls unsupported SetNormalizedRoleNameAsync

https://github.com/aspnet/Identity/blob/dev/src/Microsoft.AspNetCore.Identity/RoleManager.cs#L168

we don't allow the normalized role name to change for good reason,
but the role manager depends on this function succeeding.

also if the user has chosen a different ILookupNormalizer than the normal UpperInvariantNormalizer, the default initialisation of NormalizedRoleName in DynamoIdentityRole will not match the expected normalized role name.

querying users by email in login

In the sample project's account manager I'm trying this so I can lookup email instead of name:

var user = await _userManager.FindByEmailAsync(model.Email);
await _signInManager.PasswordSignInAsync(user, ...)

which does a _context.LoadAsync(normalizedEmail)

I can't get that to work with the GSI -- it just returns null. Is it hitting the users table instead of the index?

so I tried changing it to use the Document model Query method:

Table table = Table.LoadTable(_client, Constants.DefaultTableName);
QueryOperationConfig config = new QueryOperationConfig() 
{
    IndexName = "Email.NormalizedValue-DeletedOn-index",
    KeyExpression = new Expression()
    {
        ExpressionStatement = "Email.NormalizedValue = :e",
        ExpressionAttributeValues = new Dictionary<string, DynamoDBEntry> {
            {":e", new Primitive(normalizedEmail)}
        }
    }
};
Search search = table.Query(config);
var results = await search.GetNextSetAsync(cancellationToken);
var userDocument = results.FirstOrDefault();
user = _context.FromDocument<TUser>(userDocument);

That rejects the KeyExpression because it is on a nested attribute of the Email Map attribute.

Any tips?

(testing this with the dynamodb docker container fwiw)

Table Names

DynamoDB tables for users and roles are created using the names in appsettings.json. However, the dll is using set values (constants) for the table names: [DynamoDBTable("users")], [DynamoDBTable("roles")].

User and Role claims don't support multiple claims with the same type or value

both users and roles have the same pattern for storing claims,
and they both require that the claim types and the claim values are a set of unique items
(dynamodb does not allow inserting duplicates into a string set).

I think this is too restrictive and it denies legitimate uses of claims:
e.g. http://benfoster.io/blog/asp-net-identity-role-claims

https://docs.microsoft.com/en-us/aspnet/core/security/authorization/claims
f.t.a:
"An identity can contain multiple claims with multiple values and can contain multiple claims of the same type."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.