https://github.com/hhandoko/servicestack.authentication.lightspeed
LightSpeed ORM provider for ServiceStack authentication
https://github.com/hhandoko/servicestack.authentication.lightspeed
c-sharp lightspeed servicestack servicestack-authentication
Last synced: 3 months ago
JSON representation
LightSpeed ORM provider for ServiceStack authentication
- Host: GitHub
- URL: https://github.com/hhandoko/servicestack.authentication.lightspeed
- Owner: hhandoko
- License: bsd-3-clause
- Created: 2014-06-13T00:50:46.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-06T04:22:16.000Z (over 10 years ago)
- Last Synced: 2025-02-24T03:46:51.210Z (3 months ago)
- Topics: c-sharp, lightspeed, servicestack, servicestack-authentication
- Language: C#
- Homepage:
- Size: 1.45 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License.txt
Awesome Lists containing this project
README
ServiceStack.Authentication.LightSpeed is a [LightSpeed ORM](http://www.mindscapehq.com/products/lightspeed) provider for ServiceStack authentication.
## Prerequisites and Installation
The library does not ship with LightSpeed ORM binaries, and it expects the binaries to be available at the default installation path: `C:\Program Files (x86)\Mindscape\Bin\`.It is currently built for:
* .NET 4.5
* Mindscape LightSpeed 5
* ServiceStack 4It is available from NuGet, either via the GUI or running the following command from the Package Manager console:
```
PM> Install-Package ServiceStack.Authentication.LightSpeed
```**Dependencies:**
* ServiceStack (>= 4.0)
## Configuration
The following is an example for ASP.NET web applications. Set the unit of work context and scope in `Global.asax.cs`,```C#
authContext = new LightSpeedContext;
authScope = new PerRequestUnitOfWorkScope(authContext);
```and initialise it as normal via `AppHost.Init()` in `AppHost.cs`.
```C#
container.Register(c =>
new LightSpeedUserAuthRepository(c.Resolve())).ReusedWithin(ReuseScope.Request);
```By default, it will use the standard `JsvStringSerializer` to save complex object (e.g. roles and permissions in UserAuth).
In order to use other `IStringSerializer`, define it within the custom `UserAuthModelUnitOfWorkFactory`. The following is an example found in the [unit test](/blob/master/tests/ServiceStack.Authentication.LightSpeedTests/LightSpeedAuthProviderReadCompatibilityTest.cs):
```C#
authContext =
new LightSpeedContext
{
ConnectionString = dbConnStr,
DataProvider = DataProvider.SQLite3,
UnitOfWorkFactory = new UserAuthModelUnitOfWorkFactory(new JsvStringSerializer()),
IdentityMethod = IdentityMethod.IdentityColumn
};
```Please read the following [ServiceStack release notes](https://github.com/ServiceStack/ServiceStack/blob/081842d11c5dcf304a89f65e4491a9e92718d038/release-notes.md#pluggable-complex-type-serializers) for further information on pluggable complex type serializers.
Also note the use of `IdentityMethod.IdentityColumn` for identity generation method. Use this option to preserve full compatibility with OrmLite, as by default, LightSpeed will use the `KeyTable` implementation. More information on various LightSpeed identity generation can be found on [this page](http://www.mindscapehq.com/documentation/lightspeed/Controlling-the-Database-Mapping/Identity-Generation).
## Usage
The library implements ServiceStack's `IUserAuthRepository` interface (including `IManageRoles` for role management). Thus, the usage shall be no different from the standard `OrmLiteAuthRepository`.```C#
...
var ormLiteUser = this.OrmLiteRepository.GetUserAuthByUserName(username);
var lightspeedUser = this.LightSpeedRepository.GetUserAuthByUserName(username);
...
``````C#
...this.OrmLiteRepository.AssignRoles(ormLiteUser, roles: new Collection { "SuperAdmin" });
this.LightSpeedRepository.AssignRoles(lightspeedUser, roles: new Collection { "SuperAdmin" });
...
```Please note that at this time, role addition and removal is only supported through the repository class. Running collection methods over the UserAuth's `Roles` and `Permissions` properties (e.g. `userAuth.Roles.Add(newRole)`) will not persist the changes.
## Contributors
Please refer to the following [page](/Contributors.md) for a complete list of all contributors.## Contributing
Pull requests shall be made against `develop` branch, which will be reviewed for merging into the `master` branch.## Copyright and License
* Code and documentation copyright ServiceStack.Authentication.LightSpeed [contributors](/blob/master/Contributors.md).
* Code released under [BSD3 license](/blob/master/License.txt).
* Documentation released under [Creative Commons license](/blob/master/LicenseDocs.txt).## TODO
The following tasks shall be completed for version 1.0 milestone:
* Complete read and write compatibility unit tests
* Create repository constructors based on IDbConnection to keep similar signatures with OrmLite