-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,354 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Contributors | ||
|
||
- [hhandoko](https://github.com/hhandoko) (Herdy Handoko) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2014, ServiceStack.Authentication.LightSpeed contributors. | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
* Neither the name of the YamNet nor the names of its contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL YAMNET CONTRIBUTORS BE LIABLE FOR ANY | ||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
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 4 | ||
|
||
It 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 | ||
Use the library-provided IUnitOfWork for the dependency injection / resolution. It is a slimmed-down interface to LightSpeed's IUnitOfWork (incorporating `BeginTransaction()` and `SaveChanges()` methods only). | ||
|
||
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<DataModelUnitOfWork>; | ||
authScope = new PerRequestUnitOfWorkScope<DataModelUnitOfWork>(authContext); | ||
``` | ||
|
||
and initialise it as normal via AppHost.Init() in `AppHost.cs`. | ||
|
||
```C# | ||
container.Register<IUserAuthRepository>(c => | ||
new LightSpeedUserAuthRepository(c.Resolve<IUnitOfWork>())).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<UserAuthModelUnitOfWork> | ||
{ | ||
ConnectionString = dbConnStr, | ||
DataProvider = DataProvider.SQLite3, | ||
UnitOfWorkFactory = new UserAuthModelUnitOfWorkFactory(new JsvStringSerializer()) | ||
}; | ||
``` | ||
|
||
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. | ||
|
||
## Usage | ||
The library implements ServiceStack's IUserAuthRepository interface. Thus, the usage shall be no different from the standard OrmLiteAuthRepository. | ||
|
||
```C# | ||
... | ||
var ormLiteUser = this.OrmLiteRepository.GetUserAuthByUserName(email); | ||
var lightspeedUser = this.LightSpeedRepository.GetUserAuthByUserName(username); | ||
... | ||
``` | ||
|
||
```C# | ||
... | ||
|
||
this.OrmLiteRepository.AssignRoles(ormLiteUser, roles: new Collection<string> { "SuperAdmin" }); | ||
this.LightSpeedRepository.AssignRoles(lightspeedUser, roles: new Collection<string> { "SuperAdmin" }); | ||
... | ||
``` | ||
|
||
## Contributors | ||
Please refer to the following [page](/blob/master/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## 0.2 - In Progress | ||
* TBA | ||
|
||
## 0.1 - <small>2014/06/17</small> | ||
* Initial release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
:: ----------------------------------------------------------------------- | ||
:: <copyright file="NuGetCleanCache.cmd" company="ServiceStack.Authentication.LightSpeed"> | ||
:: Copyright (c) 2014 ServiceStack.Authentication.LightSpeed contributors | ||
:: </copyright> | ||
:: ----------------------------------------------------------------------- | ||
|
||
:: Delete existing NuGet packages in this directory | ||
del *.nupkg /s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
:: ----------------------------------------------------------------------- | ||
:: <copyright file="NuGetPack.cmd" company="ServiceStack.Authentication.LightSpeed"> | ||
:: Copyright (c) 2014 ServiceStack.Authentication.LightSpeed contributors | ||
:: </copyright> | ||
:: ----------------------------------------------------------------------- | ||
@ECHO OFF | ||
:: Accept command-line arguments: | ||
:: * [-n] : Package Name | ||
:: * [-v] : Version Number | ||
:: * [-p] : Pause console after execution | ||
:: Example: NuGetPack -n ServiceStack.Authentication.LightSpeed -v 1.0.0.0 -p | ||
|
||
:VarInit ----------------------------------------------------------------- | ||
:: Set the variables | ||
SET PackageName= | ||
SET VersionNo= | ||
SET CurrentDir=%~dp0 | ||
SET WorkingDir= | ||
SET NuGetDir=nuget | ||
SET OutputDir=nuget | ||
|
||
:: Could currently be in .nuget directory | ||
IF EXIST "%CD%\NuGet.exe" ( | ||
CD .. | ||
GOTO :ArgsLoop | ||
) | ||
|
||
:: Could currently be in nuget directory | ||
IF EXIST "%CD%\..\nuget\NuGet.exe" ( | ||
CD .. | ||
SET NuGetDir=nuget | ||
GOTO :ArgsLoop | ||
) | ||
|
||
:: Could currently be in .nuget or src directory | ||
IF EXIST "%CD%\..\.nuget\NuGet.exe" ( | ||
CD .. | ||
GOTO :ArgsLoop | ||
) | ||
|
||
:: Could currently be in project directory | ||
IF EXIST "%CD%\..\..\.nuget\NuGet.exe" ( | ||
CD ..\.. | ||
GOTO :ArgsLoop | ||
) | ||
|
||
:: Cannot find NuGet.exe | ||
ECHO Error, unable to find NuGet.exe | ||
GOTO :IsPause | ||
|
||
|
||
|
||
:ArgsLoop ---------------------------------------------------------------- | ||
IF NOT "%1"=="" ( | ||
IF "%1"=="-n" ( | ||
SET PackageName=%2 | ||
SHIFT | ||
) | ||
IF "%1"=="-v" ( | ||
SET VersionNo=%2 | ||
SHIFT | ||
) | ||
IF "%1"=="-p" ( | ||
SET Pause="TRUE" | ||
) | ||
SHIFT | ||
GOTO :ArgsLoop | ||
) | ||
GOTO :Title | ||
|
||
|
||
|
||
:Title ------------------------------------------------------------------- | ||
ECHO ---------------------------------------- | ||
ECHO NuGet Pack | ||
ECHO ---------------------------------------- | ||
IF NOT [%PackageName%]==[] ( | ||
ECHO Package Name : %PackageName% | ||
) | ||
ECHO Version Number : %VersionNo% | ||
ECHO NuGet Directory : %NuGetDir% | ||
ECHO Output Directory: %OutputDir% | ||
ECHO. | ||
GOTO :PackMain | ||
|
||
|
||
|
||
:PackMain ---------------------------------------------------------------- | ||
SET "Packages=YamNet.Client" | ||
|
||
:: Throw alert if Version Number is not defined. | ||
:: Otherwise pack a project if defined, or all project if not. | ||
IF NOT [%VersionNo%]==[] ( | ||
IF NOT [%PackageName%]==[] ( | ||
:: Pack specific DLL | ||
CALL :PackLoop %PackageName% %VersionNo% | ||
) ELSE ( | ||
:: Pack all the DLLs | ||
FOR %%G IN (%Packages%) DO ( | ||
CALL :PackLoop %%G %VersionNo% | ||
) | ||
) | ||
ECHO DLLs have been packaged. | ||
) ELSE ( | ||
ECHO Package Version "-v" value is required. | ||
) | ||
GOTO :IsPause | ||
|
||
|
||
|
||
:PackLoop ---------------------------------------------------------------- | ||
:: Pack the DLL(s) | ||
SET _PackageName=%1 | ||
SET _VersionNo=%2 | ||
|
||
:: Create output directory if it doesn't exist, otherwise NuGet will throw an error | ||
IF NOT EXIST "%OutputDir%\%_PackageName%" MKDIR "%OutputDir%\%_PackageName%" | ||
|
||
:: Package it! | ||
CALL "%NuGetDir%\NuGet.exe" pack "%OutputDir%\%_PackageName%.nuspec" -OutputDirectory "%OutputDir%\%_PackageName%" -Version %_VersionNo% | ||
ECHO. | ||
GOTO :EOF | ||
|
||
|
||
|
||
:IsPause ----------------------------------------------------------------- | ||
:: Pause console if requested. | ||
IF [%Pause%] == "TRUE" ( | ||
PAUSE | ||
) | ||
GOTO :BatchEnd | ||
|
||
|
||
|
||
:BatchEnd ---------------------------------------------------------------- | ||
:: Make sure we return to the original directory | ||
CD %CurrentDir% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> | ||
<metadata> | ||
<id>ServiceStack.Authentication.LightSpeed</id> | ||
<version>$version$</version> | ||
<title>LightSpeed ORM provider for ServiceStack.Authentication (Unofficial)</title> | ||
<authors>Herdy Handoko</authors> | ||
<owners>Herdy Handoko</owners> | ||
<licenseUrl>https://github.com/hhandoko/ServiceStack.Authentication.LightSpeed/blob/master/License.txt?raw=true</licenseUrl> | ||
<projectUrl>https://github.com/hhandoko/ServiceStack.Authentication.LightSpeed</projectUrl> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>An unofficial LightSpeed ORM provider for ServiceStack authentication.</description> | ||
<copyright>2014 ServiceStack.Authentication.LightSpeed contributors</copyright> | ||
<language>en-AU</language> | ||
<tags>ServiceStack LightSpeed</tags> | ||
<dependencies> | ||
<group> | ||
<dependency id="ServiceStack" version="4.0" /> | ||
</group> | ||
</dependencies> | ||
</metadata> | ||
<files> | ||
<file src="..\release\latest\ServiceStack.Authentication.LightSpeed\lib\ServiceStack.Authentication.LightSpeed.dll" target="lib\net45\ServiceStack.Authentication.LightSpeed.dll" /> | ||
<file src="..\release\latest\ServiceStack.Authentication.LightSpeed\readme.txt" target="readme.txt" /> | ||
</files> | ||
</package> |
Binary file added
BIN
+15.6 KB
...rviceStack.Authentication.LightSpeed/ServiceStack.Authentication.LightSpeed.0.1.0.0.nupkg
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
IMPORTANT NOTE: | ||
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\`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<repositories> | ||
<repository path="..\src\ServiceStack.Authentication.LightSpeed\packages.config" /> | ||
<repository path="..\tests\ServiceStack.Authentication.LightSpeedTests\packages.config" /> | ||
</repositories> |
40 changes: 40 additions & 0 deletions
40
src/ServiceStack.Authentication.LightSpeed/DataModel/IUnitOfWork.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="IUnitOfWork.cs" company="ServiceStack.Authentication.LightSpeed"> | ||
// Copyright (c) ServiceStack.Authentication.LightSpeed contributors 2014 | ||
// </copyright> | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
namespace ServiceStack.Authentication.LightSpeed | ||
{ | ||
using System.Data; | ||
|
||
/// <summary> | ||
/// The UnitOfWork interface. | ||
/// </summary> | ||
public interface IUnitOfWork | ||
{ | ||
/// <summary> | ||
/// Begin a database transaction. | ||
/// </summary> | ||
/// <returns>The <see cref="IDbTransaction"/>.</returns> | ||
IDbTransaction BeginTransaction(); | ||
|
||
/// <summary> | ||
/// Begin a database transaction. | ||
/// </summary> | ||
/// <param name="isolationLevel">The isolation level.</param> | ||
/// <returns>The <see cref="IDbTransaction"/>.</returns> | ||
IDbTransaction BeginTransaction(IsolationLevel isolationLevel); | ||
|
||
/// <summary> | ||
/// Persist changes to the database. | ||
/// </summary> | ||
void SaveChanges(); | ||
|
||
/// <summary> | ||
/// Persist changes to the database. | ||
/// </summary> | ||
/// <param name="reset"><c>True</c> to clear existing entities in the unit of work.</param> | ||
void SaveChanges(bool reset); | ||
} | ||
} |
Oops, something went wrong.