Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hhandoko committed Jun 17, 2014
2 parents 58dbf4b + 539055b commit 5dc7cc9
Show file tree
Hide file tree
Showing 31 changed files with 1,354 additions and 91 deletions.
3 changes: 3 additions & 0 deletions Contributors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Contributors

- [hhandoko](https://github.com/hhandoko) (Herdy Handoko)
27 changes: 27 additions & 0 deletions License.txt
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.
319 changes: 319 additions & 0 deletions LicenseDocs.txt

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions Readme.md
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
5 changes: 5 additions & 0 deletions ReleaseNotes.md
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.
7 changes: 7 additions & 0 deletions ServiceStack.Authentication.LightSpeed.sln
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SQL Scripts", "SQL Scripts"
resources\data_schema_1.0.sqlserver.sql = resources\data_schema_1.0.sqlserver.sql
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceStack.Authentication.LightSpeedTests", "tests\ServiceStack.Authentication.LightSpeedTests\ServiceStack.Authentication.LightSpeedTests.csproj", "{0A191356-64D0-4178-B2DA-C0250585C1EF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,12 +28,17 @@ Global
{4B40A44C-F71A-452F-9609-D2737955587E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B40A44C-F71A-452F-9609-D2737955587E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B40A44C-F71A-452F-9609-D2737955587E}.Release|Any CPU.Build.0 = Release|Any CPU
{0A191356-64D0-4178-B2DA-C0250585C1EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A191356-64D0-4178-B2DA-C0250585C1EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A191356-64D0-4178-B2DA-C0250585C1EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A191356-64D0-4178-B2DA-C0250585C1EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{4B40A44C-F71A-452F-9609-D2737955587E} = {A5E233DE-AF97-4FF0-92BB-0129A6FEF283}
{463E41E1-91D5-41D7-96DA-E147CBA8D2AC} = {A75110FA-FCD9-4D6D-A289-E6BD29947003}
{0A191356-64D0-4178-B2DA-C0250585C1EF} = {7437CB13-F932-4DCB-A740-17D4316B62B5}
EndGlobalSection
EndGlobal
Binary file added nuget/NuGet.exe
Binary file not shown.
8 changes: 8 additions & 0 deletions nuget/NuGetCleanCache.cmd
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
137 changes: 137 additions & 0 deletions nuget/NuGetPack.cmd
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%
26 changes: 26 additions & 0 deletions nuget/ServiceStack.Authentication.LightSpeed.nuspec
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 not shown.
2 changes: 2 additions & 0 deletions nuget/readme.txt
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\`.
5 changes: 5 additions & 0 deletions packages/repositories.config
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>
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);
}
}
Loading

0 comments on commit 5dc7cc9

Please sign in to comment.