mirror of https://github.com/Squidex/squidex.git
42 changed files with 2177 additions and 1214 deletions
@ -0,0 +1,27 @@ |
|||
// ==========================================================================
|
|||
// GravatarHelper.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
|
|||
namespace Squidex.Infrastructure |
|||
{ |
|||
public static class GravatarHelper |
|||
{ |
|||
public static string CreatePictureUrl(string email) |
|||
{ |
|||
using (var md5 = MD5.Create()) |
|||
{ |
|||
var gravatarHash = md5.ComputeHash(Encoding.UTF8.GetBytes(email.ToLowerInvariant().Trim())); |
|||
var gravatarUrl = $"https://www.gravatar.com/avatar/{gravatarHash}"; |
|||
|
|||
return gravatarUrl; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
// ==========================================================================
|
|||
// MicrosoftHandler.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.Security.Claims; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authentication.OAuth; |
|||
using Squidex.Core.Identity; |
|||
|
|||
// ReSharper disable InvertIf
|
|||
|
|||
namespace Squidex.Config.Identity |
|||
{ |
|||
public sealed class MicrosoftHandler : OAuthEvents |
|||
{ |
|||
public override Task CreatingTicket(OAuthCreatingTicketContext context) |
|||
{ |
|||
var displayName = context.User.Value<string>("displayName"); |
|||
|
|||
if (!string.IsNullOrEmpty(displayName)) |
|||
{ |
|||
context.Identity.AddClaim(new Claim(SquidexClaimTypes.SquidexDisplayName, displayName)); |
|||
} |
|||
|
|||
var id = context.User.Value<string>("id"); |
|||
|
|||
if (!string.IsNullOrEmpty(id)) |
|||
{ |
|||
var pictureUrl = $"https://apis.live.net/v5.0/{id}/picture"; |
|||
|
|||
context.Identity.AddClaim(new Claim(SquidexClaimTypes.SquidexPictureUrl, pictureUrl)); |
|||
} |
|||
|
|||
return base.CreatingTicket(context); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// ==========================================================================
|
|||
// MicrosoftIdentityUsage.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
|
|||
// ReSharper disable InvertIf
|
|||
|
|||
namespace Squidex.Config.Identity |
|||
{ |
|||
public static class MicrosoftIdentityUsage |
|||
{ |
|||
public static IApplicationBuilder UseMyMicrosoftAuthentication(this IApplicationBuilder app) |
|||
{ |
|||
var options = app.ApplicationServices.GetService<IOptions<MyIdentityOptions>>().Value; |
|||
|
|||
if (options.IsMicrosoftAuthConfigured()) |
|||
{ |
|||
var googleOptions = |
|||
new MicrosoftAccountOptions |
|||
{ |
|||
ClientId = options.MicrosoftClient, |
|||
ClientSecret = options.MicrosoftSecret, |
|||
Events = new MicrosoftHandler() |
|||
}; |
|||
|
|||
app.UseMicrosoftAccountAuthentication(googleOptions); |
|||
} |
|||
|
|||
return app; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
// ==========================================================================
|
|||
// CreateUserDto.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Squidex.Controllers.Api.Users.Models |
|||
{ |
|||
public sealed class CreateUserDto |
|||
{ |
|||
[Required] |
|||
[EmailAddress] |
|||
public string Email { get; set; } |
|||
|
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
[Required] |
|||
public string Password { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
// ==========================================================================
|
|||
// UpdateUserDto.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Squidex.Controllers.Api.Users.Models |
|||
{ |
|||
public sealed class UpdateUserDto |
|||
{ |
|||
[Required] |
|||
[EmailAddress] |
|||
public string Email { get; set; } |
|||
|
|||
[Required] |
|||
public string DisplayName { get; set; } |
|||
|
|||
public string Password { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
// ==========================================================================
|
|||
// LoginModel.cs
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex Group
|
|||
// All rights reserved.
|
|||
// ==========================================================================
|
|||
|
|||
using System.ComponentModel.DataAnnotations; |
|||
|
|||
namespace Squidex.Controllers.UI.Account |
|||
{ |
|||
public sealed class LoginModel |
|||
{ |
|||
[Required] |
|||
public string Email { get; set; } |
|||
|
|||
[Required] |
|||
public string Password { get; set; } |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
Binary file not shown.
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 56 KiB |
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Loading…
Reference in new issue