diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..95dae1a
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,28 @@
+# How to contribute
+One of the goal of Wilcommerce is growing through the contributions of the community.
+If you have any issue, features or patches to submit, please follow this few guidelines.
+
+## Getting Started
+- Make sure you have a [GitHub account](https://github.com/join)
+- Check if your feature or bug is already in our issues.
+If not [create a new issue](https://github.com/wilcommerce/Wilcommerce.Auth/issues) and describe it clearly.
+- If it's a bug include also the steps to reproduce it and tell us the Wilcommerce version you have encountered it on.
+- Fork the repository on GitHub.
+
+## Making Changes
+- Create a new feature branch in your fork starting from the develop branch.
+- Make commits of logical units.
+- Check for unnecessary whitespace with ```git diff --check``` before committing.
+- Make sure your commit messages are in the proper format.
+- Write unit tests adding your test class to the **Wilcommerce.Auth.Test** project.
+- Run **all** the tests to avoid breaking changes.
+
+## Submitting Changes
+- Push your changes to your feature branch in your fork.
+- [Submit a pull request](https://github.com/wilcommerce/Wilcommerce.Auth/pulls)
+
+# Additional Resources
+- [GitHub Documentation](https://help.github.com/)
+- [GitHub Flow](https://help.github.com/articles/github-flow/)
+- [Working with forks](https://help.github.com/articles/working-with-forks/)
+- [Submit pull request](https://help.github.com/articles/proposing-changes-to-your-work-with-pull-requests/)
\ No newline at end of file
diff --git a/README.md b/README.md
index 8e56b0d..92c5bd4 100644
--- a/README.md
+++ b/README.md
@@ -20,4 +20,7 @@ The **Services** namespace contains a set of components which gives a simple acc
This namespace contains the interface which defines the persistence of the components.
## Events
-In the **Events** namespace are defined all the events that could happen after an action made.
\ No newline at end of file
+In the **Events** namespace are defined all the events that could happen after an action made.
+
+# Contributing
+If you want to contribute to Wilcommerce please, check the [CONTRIBUTING](CONTRIBUTING.md) file.
\ No newline at end of file
diff --git a/Wilcommerce.Auth.Test/Models/UserTokenTest.cs b/Wilcommerce.Auth.Test/Models/UserTokenTest.cs
index a6412f1..d47549c 100644
--- a/Wilcommerce.Auth.Test/Models/UserTokenTest.cs
+++ b/Wilcommerce.Auth.Test/Models/UserTokenTest.cs
@@ -109,7 +109,7 @@ public void SetAsExpired_Should_Set_ExpirationDate_To_Today()
var userToken = UserToken.Registration(user, token, expirationDate);
userToken.SetAsExpired();
- Assert.Equal(true, userToken.IsExpired);
+ Assert.True(userToken.IsExpired);
Assert.Equal(DateTime.Now.ToString("yyyy-MM-dd"), userToken.ExpirationDate.ToString("yyyy-MM-dd"));
}
}
diff --git a/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.csproj b/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.csproj
new file mode 100644
index 0000000..d4b070e
--- /dev/null
+++ b/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.csproj
@@ -0,0 +1,25 @@
+
+
+
+ netcoreapp2.0
+ Wilcommerce.Auth.Test
+ Wilcommerce.Auth.Test
+ true
+ $(PackageTargetFallback);dnxcore50;portable-net45+win8
+ 2.0.0
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.xproj b/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.xproj
deleted file mode 100644
index c8e94f6..0000000
--- a/Wilcommerce.Auth.Test/Wilcommerce.Auth.Test.xproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- 14.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
-
- 0a3668d7-c428-442a-9254-3dd5683ecb31
- Wilcommerce.Auth.Test
- .\obj
- .\bin\
- v4.6.1
-
-
- 2.0
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Wilcommerce.Auth.Test/project.json b/Wilcommerce.Auth.Test/project.json
deleted file mode 100644
index b1ff637..0000000
--- a/Wilcommerce.Auth.Test/project.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "1.0.0-*",
-
- "testRunner": "xunit",
- "dependencies": {
- "NETStandard.Library": "1.6.1",
- "Wilcommerce.Auth": "1.0.0-beta1",
- "xunit": "2.1.0",
- "dotnet-test-xunit": "2.2.0-preview2-build1029"
- },
-
- "frameworks": {
- "netcoreapp1.1": {
- "dependencies": {
- "Microsoft.NETCore.App": {
- "type": "platform",
- "version": "1.1.0"
- }
- },
- "imports": [
- "dnxcore50",
- "portable-net45+win8"
- ]
- }
- }
-}
diff --git a/Wilcommerce.Auth.sln b/Wilcommerce.Auth.sln
index e1d121d..a800761 100644
--- a/Wilcommerce.Auth.sln
+++ b/Wilcommerce.Auth.sln
@@ -1,21 +1,23 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D3477DCE-8BF1-426D-988D-E635FA87D1E6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04E04DDE-9D8E-4FF2-8E33-A77BDB05407F}"
ProjectSection(SolutionItems) = preProject
- global.json = global.json
+ .gitignore = .gitignore
+ CONTRIBUTING.md = CONTRIBUTING.md
+ LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Wilcommerce.Auth", "src\Wilcommerce.Auth\Wilcommerce.Auth.xproj", "{44A956D2-E32F-49D9-A4D1-3380C0F6DCF7}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{D9B968BF-5C00-485C-90F8-105B2B70C349}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Wilcommerce.Auth.Test", "Wilcommerce.Auth.Test\Wilcommerce.Auth.Test.xproj", "{0A3668D7-C428-442A-9254-3DD5683ECB31}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wilcommerce.Auth", "src\Wilcommerce.Auth\Wilcommerce.Auth.csproj", "{44A956D2-E32F-49D9-A4D1-3380C0F6DCF7}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wilcommerce.Auth.Test", "Wilcommerce.Auth.Test\Wilcommerce.Auth.Test.csproj", "{0A3668D7-C428-442A-9254-3DD5683ECB31}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -39,4 +41,7 @@ Global
{44A956D2-E32F-49D9-A4D1-3380C0F6DCF7} = {D3477DCE-8BF1-426D-988D-E635FA87D1E6}
{0A3668D7-C428-442A-9254-3DD5683ECB31} = {D9B968BF-5C00-485C-90F8-105B2B70C349}
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {A16E1AA2-E3B8-45F0-853E-0C884A118FCC}
+ EndGlobalSection
EndGlobal
diff --git a/global.json b/global.json
deleted file mode 100644
index 8b163c5..0000000
--- a/global.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "projects": [ "src", "test" ],
- "sdk": {
- "version": "1.0.0-preview2-1-003177"
- }
-}
diff --git a/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IRecoverPasswordCommandHandler.cs b/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IRecoverPasswordCommandHandler.cs
index 1f1b797..00e2b62 100644
--- a/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IRecoverPasswordCommandHandler.cs
+++ b/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IRecoverPasswordCommandHandler.cs
@@ -2,6 +2,9 @@
namespace Wilcommerce.Auth.Commands.Handlers.Interfaces
{
+ ///
+ /// Performs the password recovery action
+ ///
public interface IRecoverPasswordCommandHandler : ICommandHandlerAsync
{
}
diff --git a/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IValidatePasswordRecoveryCommandHandler.cs b/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IValidatePasswordRecoveryCommandHandler.cs
index f2fa789..cbbadad 100644
--- a/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IValidatePasswordRecoveryCommandHandler.cs
+++ b/src/Wilcommerce.Auth/Commands/Handlers/Interfaces/IValidatePasswordRecoveryCommandHandler.cs
@@ -2,6 +2,9 @@
namespace Wilcommerce.Auth.Commands.Handlers.Interfaces
{
+ ///
+ /// Performs the validation for the password recovery request
+ ///
public interface IValidatePasswordRecoveryCommandHandler : ICommandHandlerAsync
{
}
diff --git a/src/Wilcommerce.Auth/Commands/Handlers/RecoverPasswordCommandHandler.cs b/src/Wilcommerce.Auth/Commands/Handlers/RecoverPasswordCommandHandler.cs
index c29d605..68929b1 100644
--- a/src/Wilcommerce.Auth/Commands/Handlers/RecoverPasswordCommandHandler.cs
+++ b/src/Wilcommerce.Auth/Commands/Handlers/RecoverPasswordCommandHandler.cs
@@ -6,18 +6,37 @@
namespace Wilcommerce.Auth.Commands.Handlers
{
+ ///
+ /// Implementation of
+ ///
public class RecoverPasswordCommandHandler : Interfaces.IRecoverPasswordCommandHandler
{
+ ///
+ /// Get the event bus
+ ///
public Core.Infrastructure.IEventBus EventBus { get; }
+ ///
+ /// Get the authentication repository
+ ///
public IRepository Repository { get; }
+ ///
+ /// Construct the command handler
+ ///
+ /// The repository instance
+ /// The event bus instance
public RecoverPasswordCommandHandler(IRepository repository, Core.Infrastructure.IEventBus eventBus)
{
Repository = repository;
EventBus = eventBus;
}
+ ///
+ /// Recover the password for the user
+ ///
+ /// The command to execute
+ ///
public async Task Handle(RecoverPasswordCommand command)
{
try
@@ -27,7 +46,7 @@ public async Task Handle(RecoverPasswordCommand command)
Repository.Add(userToken);
await Repository.SaveChangesAsync();
- var @event = new PasswordRecoveryRequestedEvent(userToken.UserId, userToken.User.Email, userToken.Id, userToken.Token, userToken.ExpirationDate);
+ var @event = new PasswordRecoveryRequestedEvent(userToken.UserId, command.UserInfo.Email, userToken.Id, userToken.Token, userToken.ExpirationDate);
EventBus.RaiseEvent(@event);
}
catch
diff --git a/src/Wilcommerce.Auth/Commands/Handlers/ValidatePasswordRecoveryCommandHandler.cs b/src/Wilcommerce.Auth/Commands/Handlers/ValidatePasswordRecoveryCommandHandler.cs
index 708de70..b794011 100644
--- a/src/Wilcommerce.Auth/Commands/Handlers/ValidatePasswordRecoveryCommandHandler.cs
+++ b/src/Wilcommerce.Auth/Commands/Handlers/ValidatePasswordRecoveryCommandHandler.cs
@@ -7,14 +7,32 @@
namespace Wilcommerce.Auth.Commands.Handlers
{
+ ///
+ /// Implementation of
+ ///
public class ValidatePasswordRecoveryCommandHandler : Interfaces.IValidatePasswordRecoveryCommandHandler
{
+ ///
+ /// Get the authentication database
+ ///
public IAuthDatabase Database { get; }
+ ///
+ /// Get the authentication repository
+ ///
public IRepository Repository { get; }
+ ///
+ /// Get the event bus
+ ///
public Core.Infrastructure.IEventBus EventBus { get; }
+ ///
+ /// Construct the command handler
+ ///
+ /// The database instance
+ /// The repository instance
+ /// The event bus instance
public ValidatePasswordRecoveryCommandHandler(IAuthDatabase database, IRepository repository, Core.Infrastructure.IEventBus eventBus)
{
Database = database;
@@ -22,6 +40,11 @@ public ValidatePasswordRecoveryCommandHandler(IAuthDatabase database, IRepositor
EventBus = eventBus;
}
+ ///
+ /// Validate the password recovery request
+ ///
+ /// The command to execute
+ ///
public async Task Handle(ValidatePasswordRecoveryCommand command)
{
try
diff --git a/src/Wilcommerce.Auth/Commands/RecoverPasswordCommand.cs b/src/Wilcommerce.Auth/Commands/RecoverPasswordCommand.cs
index b45b7ce..fbd8066 100644
--- a/src/Wilcommerce.Auth/Commands/RecoverPasswordCommand.cs
+++ b/src/Wilcommerce.Auth/Commands/RecoverPasswordCommand.cs
@@ -3,12 +3,26 @@
namespace Wilcommerce.Auth.Commands
{
+ ///
+ /// Recover the user password
+ ///
public class RecoverPasswordCommand : ICommand
{
+ ///
+ /// Get the user information
+ ///
public User UserInfo { get; }
+ ///
+ /// Get the recovery token
+ ///
public string Token { get; }
+ ///
+ /// Construct the command
+ ///
+ /// The user information
+ /// The recovery token
public RecoverPasswordCommand(User user, string token)
{
UserInfo = user;
diff --git a/src/Wilcommerce.Auth/Commands/ValidatePasswordRecoveryCommand.cs b/src/Wilcommerce.Auth/Commands/ValidatePasswordRecoveryCommand.cs
index f1d524e..addae1f 100644
--- a/src/Wilcommerce.Auth/Commands/ValidatePasswordRecoveryCommand.cs
+++ b/src/Wilcommerce.Auth/Commands/ValidatePasswordRecoveryCommand.cs
@@ -2,10 +2,20 @@
namespace Wilcommerce.Auth.Commands
{
+ ///
+ /// Validate the password recovery request
+ ///
public class ValidatePasswordRecoveryCommand : ICommand
{
+ ///
+ /// Get the recovery token
+ ///
public string Token { get; }
+ ///
+ /// Construct the command
+ ///
+ /// The recovery token
public ValidatePasswordRecoveryCommand(string token)
{
Token = token;
diff --git a/src/Wilcommerce.Auth/Events/User/Handlers/UserEventHandler.cs b/src/Wilcommerce.Auth/Events/User/Handlers/UserEventHandler.cs
index a9e6360..04be3d9 100644
--- a/src/Wilcommerce.Auth/Events/User/Handlers/UserEventHandler.cs
+++ b/src/Wilcommerce.Auth/Events/User/Handlers/UserEventHandler.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Http.Authentication;
+using Microsoft.AspNetCore.Authentication;
+using Microsoft.AspNetCore.Http;
using System;
using System.Linq;
using Wilcommerce.Auth.Services.Interfaces;
@@ -7,30 +8,50 @@
namespace Wilcommerce.Auth.Events.User.Handlers
{
+ ///
+ /// Handles all the events related to the user
+ ///
public class UserEventHandler :
IHandleEvent,
IHandleEvent,
IHandleEvent
{
+ ///
+ /// Get the event store
+ ///
public IEventStore EventStore { get; }
+ ///
+ /// Get the identity factory
+ ///
public IIdentityFactory IdentityFactory { get; }
+ ///
+ /// Get the database of the common context
+ ///
public ICommonDatabase CommonDatabase { get; }
///
- /// Get the OWIN Authentication manager
+ /// Get the http context
///
- public AuthenticationManager AuthenticationManager { get; }
+ public HttpContext Context { get; }
- public UserEventHandler(IEventStore eventStore, IIdentityFactory identityFactory, ICommonDatabase commonDatabase, AuthenticationManager authenticationManager)
+ ///
+ /// Construct the event handler
+ ///
+ /// The event store instance
+ /// The identity factory instance
+ /// The common database instance
+ /// The http context instance
+ public UserEventHandler(IEventStore eventStore, IIdentityFactory identityFactory, ICommonDatabase commonDatabase, HttpContext httpContext)
{
EventStore = eventStore;
IdentityFactory = identityFactory;
CommonDatabase = commonDatabase;
- AuthenticationManager = authenticationManager;
+ Context = httpContext;
}
+ ///
public void Handle(UserSignedInEvent @event)
{
try
@@ -43,6 +64,7 @@ public void Handle(UserSignedInEvent @event)
}
}
+ ///
public void Handle(PasswordRecoveryRequestedEvent @event)
{
try
@@ -55,6 +77,7 @@ public void Handle(PasswordRecoveryRequestedEvent @event)
}
}
+ ///
public void Handle(PasswordRecoveryValidatedEvent @event)
{
try
@@ -70,7 +93,7 @@ public void Handle(PasswordRecoveryValidatedEvent @event)
}
var principal = IdentityFactory.CreateIdentity(user);
- AuthenticationManager.SignInAsync(AuthenticationDefaults.AuthenticationScheme, principal);
+ Context.SignInAsync(AuthenticationDefaults.AuthenticationScheme, principal);
}
catch
{
diff --git a/src/Wilcommerce.Auth/Events/User/PasswordRecoveryRequestedEvent.cs b/src/Wilcommerce.Auth/Events/User/PasswordRecoveryRequestedEvent.cs
index 4300581..a6bb562 100644
--- a/src/Wilcommerce.Auth/Events/User/PasswordRecoveryRequestedEvent.cs
+++ b/src/Wilcommerce.Auth/Events/User/PasswordRecoveryRequestedEvent.cs
@@ -3,16 +3,39 @@
namespace Wilcommerce.Auth.Events.User
{
+ ///
+ /// Password recovery validated
+ ///
public class PasswordRecoveryRequestedEvent : DomainEvent
{
+ ///
+ /// Get the username
+ ///
public string Username { get; }
+ ///
+ /// Get the token id
+ ///
public Guid TokenId { get; }
+ ///
+ /// Get the password recovery token
+ ///
public string Token { get; }
+ ///
+ /// Get the token expiration date
+ ///
public DateTime ExpirationDate { get; }
+ ///
+ /// Construct the event
+ ///
+ /// The user id
+ /// The username
+ /// The token id
+ /// The password recovery token
+ /// The token expiration date
public PasswordRecoveryRequestedEvent(Guid userId, string username, Guid tokenId, string token, DateTime expirationDate)
: base(userId, typeof(Core.Common.Domain.Models.User))
{
diff --git a/src/Wilcommerce.Auth/Events/User/PasswordRecoveryValidatedEvent.cs b/src/Wilcommerce.Auth/Events/User/PasswordRecoveryValidatedEvent.cs
index 8c7e0e7..ecc5815 100644
--- a/src/Wilcommerce.Auth/Events/User/PasswordRecoveryValidatedEvent.cs
+++ b/src/Wilcommerce.Auth/Events/User/PasswordRecoveryValidatedEvent.cs
@@ -3,10 +3,21 @@
namespace Wilcommerce.Auth.Events.User
{
+ ///
+ /// Password recovery validated
+ ///
public class PasswordRecoveryValidatedEvent : DomainEvent
{
+ ///
+ /// Get the password recovery token
+ ///
public string Token { get; }
+ ///
+ /// Construct the event
+ ///
+ /// The user id
+ /// The password recovery token
public PasswordRecoveryValidatedEvent(Guid userId, string token)
: base(userId, typeof(Core.Common.Domain.Models.User))
{
diff --git a/src/Wilcommerce.Auth/Events/User/UserSignedInEvent.cs b/src/Wilcommerce.Auth/Events/User/UserSignedInEvent.cs
index a9d1467..ff0ae32 100644
--- a/src/Wilcommerce.Auth/Events/User/UserSignedInEvent.cs
+++ b/src/Wilcommerce.Auth/Events/User/UserSignedInEvent.cs
@@ -3,10 +3,21 @@
namespace Wilcommerce.Auth.Events.User
{
+ ///
+ /// User signed in
+ ///
public class UserSignedInEvent : DomainEvent
{
+ ///
+ /// Get the username
+ ///
public string Username { get; }
+ ///
+ /// Construct the event
+ ///
+ /// The user id
+ /// The username
public UserSignedInEvent(Guid userId, string username)
: base(userId, typeof(Core.Common.Domain.Models.User))
{
diff --git a/src/Wilcommerce.Auth/Models/UserToken.cs b/src/Wilcommerce.Auth/Models/UserToken.cs
index 54e068c..930421e 100644
--- a/src/Wilcommerce.Auth/Models/UserToken.cs
+++ b/src/Wilcommerce.Auth/Models/UserToken.cs
@@ -9,14 +9,12 @@ namespace Wilcommerce.Auth.Models
///
public class UserToken : IAggregateRoot
{
- public Guid Id { get; set; }
-
- #region Properties
///
- /// Get the related user
+ /// Get the entity id
///
- public virtual User User { get; protected set; }
+ public Guid Id { get; protected set; }
+ #region Properties
///
/// Get the related user id
///
diff --git a/src/Wilcommerce.Auth/ReadModels/Extensions/UserTokenExtensions.cs b/src/Wilcommerce.Auth/ReadModels/Extensions/UserTokenExtensions.cs
index eb03703..998974c 100644
--- a/src/Wilcommerce.Auth/ReadModels/Extensions/UserTokenExtensions.cs
+++ b/src/Wilcommerce.Auth/ReadModels/Extensions/UserTokenExtensions.cs
@@ -4,8 +4,17 @@
namespace Wilcommerce.Auth.ReadModels
{
+ ///
+ /// Defines the extension methods for the read models
+ ///
public static class UserTokenExtensions
{
+ ///
+ /// Retrieve all the user tokens by the user id
+ ///
+ /// The instance to which attach this method
+ /// The user id
+ /// A list of user tokens
public static IQueryable ByUser(this IQueryable tokens, Guid userId)
{
return from t in tokens
@@ -13,6 +22,11 @@ public static IQueryable ByUser(this IQueryable tokens, Gu
select t;
}
+ ///
+ /// Retrieve all the expired tokens
+ ///
+ /// The instance to which attach this method
+ /// A list of user tokens
public static IQueryable Expired(this IQueryable tokens)
{
return from t in tokens
@@ -20,6 +34,11 @@ public static IQueryable Expired(this IQueryable tokens)
select t;
}
+ ///
+ /// Retrieve all the user tokens which are not expired
+ ///
+ /// The instance to which attach this method
+ /// A list of user tokens
public static IQueryable NotExpired(this IQueryable tokens)
{
return from t in tokens
@@ -27,6 +46,12 @@ public static IQueryable NotExpired(this IQueryable tokens
select t;
}
+ ///
+ /// Retrieve all the user tokens filtered by the type
+ ///
+ /// The instance to which attach this method
+ /// The token type
+ /// A list of user tokens
public static IQueryable ByTokenType(this IQueryable tokens, string type)
{
return from t in tokens
diff --git a/src/Wilcommerce.Auth/Repository/IRepository.cs b/src/Wilcommerce.Auth/Repository/IRepository.cs
index bb7fefb..95a527c 100644
--- a/src/Wilcommerce.Auth/Repository/IRepository.cs
+++ b/src/Wilcommerce.Auth/Repository/IRepository.cs
@@ -1,5 +1,6 @@
namespace Wilcommerce.Auth.Repository
{
+ ///
public interface IRepository : Core.Infrastructure.IRepository
{
}
diff --git a/src/Wilcommerce.Auth/Services/AuthenticationService.cs b/src/Wilcommerce.Auth/Services/AuthenticationService.cs
index 7533341..ceaf960 100644
--- a/src/Wilcommerce.Auth/Services/AuthenticationService.cs
+++ b/src/Wilcommerce.Auth/Services/AuthenticationService.cs
@@ -1,5 +1,4 @@
-using Microsoft.AspNetCore.Http.Authentication;
-using System;
+using System;
using System.Linq;
using System.Threading.Tasks;
using Wilcommerce.Core.Common.Domain.Models;
@@ -10,18 +9,20 @@
using Wilcommerce.Auth.Commands;
using Wilcommerce.Core.Infrastructure;
using Wilcommerce.Auth.Events.User;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Authentication;
namespace Wilcommerce.Auth.Services
{
///
- /// Defines the implementations for the authentication actions
+ /// Implementation of
///
- public class AuthenticationService : IAuthenticationService
+ public class AuthenticationService : Interfaces.IAuthenticationService
{
///
- /// Get the OWIN Authentication manager
+ /// Get the http context
///
- public AuthenticationManager AuthenticationManager { get; }
+ public HttpContext Context { get; }
///
/// Get the common context database
@@ -58,9 +59,20 @@ public class AuthenticationService : IAuthenticationService
///
public IEventBus EventBus { get; }
- public AuthenticationService(AuthenticationManager authenticationManager, ICommonDatabase commonDatabase, IPasswordHasher passwordHasher, ITokenGenerator tokenGenerator, IRecoverPasswordCommandHandler recoverPasswordHandler, IValidatePasswordRecoveryCommandHandler validatePasswordRecoveryHandler, IEventBus eventBus, IIdentityFactory identityFactory)
+ ///
+ /// Construct the authentication service
+ ///
+ /// The http context instance
+ /// The common database instance
+ /// The password hasher instance
+ /// The token generator instance
+ /// The password recover handler instance
+ /// The password recovery validation handler instance
+ /// The event bus instance
+ /// The identity factory instance
+ public AuthenticationService(HttpContext httpContext, ICommonDatabase commonDatabase, IPasswordHasher passwordHasher, ITokenGenerator tokenGenerator, IRecoverPasswordCommandHandler recoverPasswordHandler, IValidatePasswordRecoveryCommandHandler validatePasswordRecoveryHandler, IEventBus eventBus, IIdentityFactory identityFactory)
{
- AuthenticationManager = authenticationManager;
+ Context = httpContext;
CommonDatabase = commonDatabase;
PasswordHasher = passwordHasher;
TokenGenerator = tokenGenerator;
@@ -70,7 +82,7 @@ public AuthenticationService(AuthenticationManager authenticationManager, ICommo
IdentityFactory = identityFactory;
}
- ///
+ ///
public Task SignIn(string email, string password, bool isPersistent)
{
try
@@ -90,7 +102,7 @@ public Task SignIn(string email, string password, bool isPersistent)
}
var principal = IdentityFactory.CreateIdentity(user);
- var signin = AuthenticationManager.SignInAsync(
+ var signin = Context.SignInAsync(
AuthenticationDefaults.AuthenticationScheme,
principal,
new AuthenticationProperties { IsPersistent = isPersistent });
@@ -106,12 +118,12 @@ public Task SignIn(string email, string password, bool isPersistent)
}
}
- ///
+ ///
public Task SignOut()
{
try
{
- return AuthenticationManager.SignOutAsync(AuthenticationDefaults.AuthenticationScheme);
+ return Context.SignOutAsync(AuthenticationDefaults.AuthenticationScheme);
}
catch
{
@@ -119,7 +131,7 @@ public Task SignOut()
}
}
- ///
+ ///
public Task RecoverPassword(string email)
{
try
@@ -142,7 +154,7 @@ public Task RecoverPassword(string email)
}
}
- ///
+ ///
public Task ValidatePasswordRecovery(string token)
{
try
diff --git a/src/Wilcommerce.Auth/Services/IdentityFactory.cs b/src/Wilcommerce.Auth/Services/IdentityFactory.cs
index 439b200..54b42c1 100644
--- a/src/Wilcommerce.Auth/Services/IdentityFactory.cs
+++ b/src/Wilcommerce.Auth/Services/IdentityFactory.cs
@@ -6,11 +6,11 @@
namespace Wilcommerce.Auth.Services
{
///
- /// Defines the implementation for the identity factory
+ /// Implementation of
///
public class IdentityFactory : IIdentityFactory
{
- ///
+ ///
public virtual ClaimsPrincipal CreateIdentity(User user)
{
try
diff --git a/src/Wilcommerce.Auth/Services/Interfaces/IIdentityFactory.cs b/src/Wilcommerce.Auth/Services/Interfaces/IIdentityFactory.cs
index ace3148..6e89690 100644
--- a/src/Wilcommerce.Auth/Services/Interfaces/IIdentityFactory.cs
+++ b/src/Wilcommerce.Auth/Services/Interfaces/IIdentityFactory.cs
@@ -11,7 +11,7 @@ public interface IIdentityFactory
///
/// Create the claims principal by the user
///
- /// The user for which creates the indentity
+ /// The user for which creates the identity
/// The claims principal
ClaimsPrincipal CreateIdentity(User user);
}
diff --git a/src/Wilcommerce.Auth/Services/Interfaces/ITokenGenerator.cs b/src/Wilcommerce.Auth/Services/Interfaces/ITokenGenerator.cs
index 24c6724..bed1ddf 100644
--- a/src/Wilcommerce.Auth/Services/Interfaces/ITokenGenerator.cs
+++ b/src/Wilcommerce.Auth/Services/Interfaces/ITokenGenerator.cs
@@ -2,8 +2,16 @@
namespace Wilcommerce.Auth.Services.Interfaces
{
+ ///
+ /// Represents the token generator interface
+ ///
public interface ITokenGenerator
{
+ ///
+ /// Generate a token string for the specified user
+ ///
+ /// The current user
+ /// The token string
string GenerateForUser(User user);
}
}
diff --git a/src/Wilcommerce.Auth/Services/TokenGenerator.cs b/src/Wilcommerce.Auth/Services/TokenGenerator.cs
index 1514b2f..f7d73f9 100644
--- a/src/Wilcommerce.Auth/Services/TokenGenerator.cs
+++ b/src/Wilcommerce.Auth/Services/TokenGenerator.cs
@@ -5,8 +5,12 @@
namespace Wilcommerce.Auth.Services
{
+ ///
+ /// Implementation of
+ ///
public class TokenGenerator : ITokenGenerator
{
+ ///
public string GenerateForUser(User user)
{
try
diff --git a/src/Wilcommerce.Auth/Wilcommerce.Auth.csproj b/src/Wilcommerce.Auth/Wilcommerce.Auth.csproj
new file mode 100644
index 0000000..2a6465d
--- /dev/null
+++ b/src/Wilcommerce.Auth/Wilcommerce.Auth.csproj
@@ -0,0 +1,43 @@
+
+
+
+ 1.0.0
+ Alberto Mori
+ netstandard2.0
+ Wilcommerce.Auth
+ Wilcommerce.Auth
+ wilcommerce;ecommerce;opensource;.netcore;.net;authentication;owin;identity
+ http://www.wilcommerce.com/logo64.png
+ https://github.com/wilcommerce/Wilcommerce.Auth
+ https://github.com/wilcommerce/Wilcommerce.Auth/blob/master/LICENSE
+ git
+ https://github.com/wilcommerce/Wilcommerce.Auth
+ false
+ false
+ false
+ 1.0.0-rc1
+ Upgrade to .NET Standard 2.0 & .NET Core 2.0
+ Wilcommerce Authentication and Authorization library
+
+
+
+ bin\Debug\netstandard2.0\Wilcommerce.Auth.xml
+
+
+
+ bin\Release\netstandard2.0\Wilcommerce.Auth.xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Wilcommerce.Auth/Wilcommerce.Auth.xproj b/src/Wilcommerce.Auth/Wilcommerce.Auth.xproj
deleted file mode 100644
index 26b66fd..0000000
--- a/src/Wilcommerce.Auth/Wilcommerce.Auth.xproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- 14.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
-
-
- 44a956d2-e32f-49d9-a4d1-3380c0f6dcf7
- Wilcommerce.Auth
- .\obj
- .\bin\
- v4.6.1
-
-
-
- 2.0
-
-
-
diff --git a/src/Wilcommerce.Auth/project.json b/src/Wilcommerce.Auth/project.json
deleted file mode 100644
index e7415fc..0000000
--- a/src/Wilcommerce.Auth/project.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
- "authors": [ "Alberto Mori" ],
- "dependencies": {
- "Microsoft.AspNetCore.Authentication.Cookies": "1.1.2",
- "Microsoft.AspNetCore.Owin": "1.1.2",
- "NETStandard.Library": "1.6.1",
- "Wilcommerce.Core.Common": "1.0.0-beta4",
- "System.Linq.Queryable": "4.3.0",
- "Microsoft.AspNetCore.Identity": "1.1.2"
- },
- "frameworks": {
- "netstandard1.6": {
- "imports": "dnxcore50"
- }
- },
- "packOptions": {
- "iconUrl": "http://www.wilcommerce.com/logo64.png",
- "licenseUrl": "https://github.com/wilcommerce/Wilcommerce.Auth/blob/master/LICENSE",
- "owners": [ "Alberto Mori" ],
- "projectUrl": "https://github.com/wilcommerce/Wilcommerce.Auth",
- "repository": {
- "type": "git",
- "url": "https://github.com/wilcommerce/Wilcommerce.Auth"
- },
- "summary": "Wilcommerce Authentication library",
- "tags": [ "wilcommerce", "ecommerce", "opensource", ".netcore", ".net", "authentication", "owin", "identity" ]
- },
- "version": "1.0.0-beta1"
-}