Coder Social home page Coder Social logo

identityserver4.contrib.cosmosdb's People

Contributors

jnhaffey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

identityserver4.contrib.cosmosdb's Issues

Indexing path '\/expiration' could not be accepted

Hi,

I'm receiving the following exception on app start.

DocumentClientException: Message: {"Errors":["The indexing path '/expiration' could not be accepted, failed near position '11'. Please ensure that the path is a valid path. Common errors include invalid characters or absence of quotes around labels."]}
ActivityId: 8b0de663-959d-4b57-b75c-243db171ca81, Request URI: /apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats: , SDK: Microsoft.Azure.Documents.Common/1.22.0.0

It occurs during app.UseIdentityServer():

When using InMemoryPersistentGrants, ConfigurationStore seems to work fine :)

Fixing ClientStore & PersistedGrantStore

Hi! Hopping on here to save some people some time who want to use this project as a launchboard for having cosmosDB with identityserver like moi.

This project does not actually store grants in cosmos DB in its current state. To persist them, you need to fix code in IdentityServer4.Contrib.CosmosDB.Stores.PersistedGrantStore.StoreAsync()

You should replace SingleOrDefault() on line 31 to:
var existing = _context.PersistedGrants().Where(x => x.Key == token.Key).Take(1).AsEnumerable().SingleOrDefault(); //or some equivalent statement you prefer, it might be more performant to do this on x.Id

This is micrososft's recommendation for their library's unimplemented SingleOrDefault() (see: https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/6771773-add-support-for-single-entity-retrieval-instead-of). You've got to do this, because SingleOrDefault() will trigger an exception from their library (unsupported query).

For performance reasons, you also aught to change
var client = _context.Clients(clientId).FirstOrDefault(x => x.ClientId == clientId);

to

var clients = _context.Clients(clientId).Where(x => x.ClientId == clientId).Take(1).AsEnumerable();

in IdentityServer4.Contrib.CosmosDB.Stores.ClientStore.FindClientByIdAsync(), as this should be more performant than returning all documents and then doing a singleordefault

FindApiResourceAsync I also think has this issue with it too, I forget. I'll see if I can get this all working and put together some kind of a PR I guess. Even if it never gets incorporated it might get a real fix jumpstarted.

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.