Giter Site home page Giter Site logo

mdissel / servicestack.authentication.marten Goto Github PK

View Code? Open in Web Editor NEW

This project forked from migajek/servicestack.authentication.marten

0.0 2.0 0.0 1.33 MB

ServiceStack UserAuthRepository implementation using Marten Document Store

Batchfile 0.67% C# 99.33%

servicestack.authentication.marten's Introduction

ServiceStack.Authentication.Marten

This project provides an implementation of ServiceStack's UserAuthRepository using Marten for storage.

Key features

  • supports .NET 4.6 and .NET Core
  • handles user & role/permission management (implements IUserAuthRepository, IManageRoles)
  • it's generic: supports custom implementations of UserAuth and UserAuthDetails
  • can manage the IDocumentSession on it's own, or reuse the request-scoped session

Getting started

  1. install it via nuget Install-Package ServiceStack.Authentication.Marten

  2. when configuring Marten, use an AuthRepository() extension method to configure the storage for both UserAuth and UserAuthDetails types (or your own implementations, when using generic version)

    DocumentStore.For(opts =>
             {      
                 opts.AuthRepository()
                     .UseAuth<UserAuth>()
                     .UseAuthDetails<UserAuthDetails>();
             });
  3. register the auth repository in the container

    • either provide IDocumentStore to constructor, to let it handle the session on it's own:
    // ex.: container.Register<IDocumentStore>(c => new DocumentStoreBuilder().Build())
    //            .ReusedWithin(ReuseScope.Hierarchy);
    container.Register<IUserAuthRepository>(c => new MartenAuthRepository(c.Resolve<IDocumentStore>()))
                .ReusedWithin(ReuseScope.Hierarchy);
    • or provide IDocumentSession, to reuse per-request session
    // ex. container.Register(c => c.Resolve<IDocumentStore>().OpenSession())
    //            .ReusedWithin(ReuseScope.Request);
    container.Register<IUserAuthRepository>(c => new MartenAuthRepository(c.Resolve<IDocumentSession>()))
                .ReusedWithin(ReuseScope.Request);

Missing features / roadmap

  • no support for Marten as Event Store (yet ..)
  • optional StoreChanges call when re-using IDocumentSession
  • full test coverage

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.