-
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
1 parent
97f018b
commit 40dd81a
Showing
376 changed files
with
78,640 additions
and
1,090 deletions.
There are no files selected for viewing
Binary file modified
BIN
+282 KB
(540%)
Microservices/.vs/Microservices/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file removed
BIN
-14.8 KB
Microservices/.vs/Microservices/FileContentIndex/1e46f20a-c597-497d-9038-ecc0d2db67fa.vsidx
Binary file not shown.
Binary file added
BIN
+1.84 MB
Microservices/.vs/Microservices/FileContentIndex/740f87cd-fcbc-4ef6-9935-de22a36516b9.vsidx
Binary file not shown.
Binary file removed
BIN
-611 Bytes
Microservices/.vs/Microservices/FileContentIndex/8d7ccf1c-3b70-42b4-878b-9ce6d5b6364d.vsidx
Binary file not shown.
Binary file removed
BIN
-45.3 KB
Microservices/.vs/Microservices/FileContentIndex/c0e5bbe4-6275-4f71-afcc-3bab9ed888de.vsidx
Binary file not shown.
Binary file removed
BIN
-4.53 KB
Microservices/.vs/Microservices/FileContentIndex/dcdacf5d-ec61-4ca9-8ca1-6d38f686c3f5.vsidx
Binary file not shown.
1,011 changes: 0 additions & 1,011 deletions
1,011
Microservices/.vs/Microservices/config/applicationhost.config
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+56 KB
(130%)
Microservices/.vs/ProjectEvaluation/microservices.metadata.v5.2
Binary file not shown.
Binary file modified
BIN
+172 KB
(190%)
Microservices/.vs/ProjectEvaluation/microservices.projects.v5.2
Binary file not shown.
63 changes: 63 additions & 0 deletions
63
Microservices/IdentityServer/FreeCourse.IdentityServer/Config.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,63 @@ | ||
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
using IdentityServer4; | ||
using IdentityServer4.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace FreeCourse.IdentityServer | ||
{ | ||
public static class Config | ||
{ | ||
public static IEnumerable<ApiResource> ApiResources => new ApiResource[] | ||
{ | ||
new ApiResource("resource_catalog"){Scopes= {"catalog_fullpermission"} }, | ||
new ApiResource("photo_stock_catalog"){Scopes= { "photo_stock_fullpermission" } }, | ||
new ApiResource(IdentityServerConstants.LocalApi.ScopeName) | ||
}; | ||
|
||
public static IEnumerable<IdentityResource> IdentityResources => | ||
new IdentityResource[] | ||
{ | ||
new IdentityResources.Email(), //email | ||
new IdentityResources.OpenId(),//sub | ||
new IdentityResources.Profile(), | ||
new IdentityResource(){Name = "roles",DisplayName = "Role", Description="Kullanıcı Rolleri",UserClaims=new[]{ "role"} }, | ||
}; | ||
|
||
public static IEnumerable<ApiScope> ApiScopes => | ||
new ApiScope[] | ||
{ | ||
new ApiScope("catalog_fullpermission","Catalog API icin full erisim"), | ||
new ApiScope("photo_stock_fullpermission","Photo Stock API icin full erisim"), | ||
new ApiScope(IdentityServerConstants.LocalApi.ScopeName) | ||
}; | ||
|
||
public static IEnumerable<Client> Clients => | ||
new Client[] | ||
{ | ||
new Client | ||
{ | ||
ClientId = "WebMvcClient", | ||
ClientName = "Asp.Net Core MVC", | ||
ClientSecrets = { new Secret("secret".Sha256())}, | ||
AllowedGrantTypes = GrantTypes.ClientCredentials, | ||
AllowedScopes= { "catalog_fullpermission", "photo_stock_fullpermission",IdentityServerConstants.LocalApi.ScopeName } | ||
}, | ||
new Client | ||
{ | ||
ClientId = "WebMvcClientForUser", | ||
ClientName = "Asp.Net Core MVC", | ||
AllowOfflineAccess = true, | ||
ClientSecrets = { new Secret("secret".Sha256())}, | ||
AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, | ||
AllowedScopes= { IdentityServerConstants.StandardScopes.OpenId, IdentityServerConstants.StandardScopes.Email, IdentityServerConstants.StandardScopes.Profile, IdentityServerConstants.StandardScopes.OfflineAccess, IdentityServerConstants.LocalApi.ScopeName, "roles" }, | ||
AccessTokenLifetime = 1*60*60, // 1 saat | ||
RefreshTokenExpiration = TokenExpiration.Absolute, | ||
AbsoluteRefreshTokenLifetime= (int)(DateTime.Now.AddDays(60)-DateTime.Now).TotalSeconds, // 60 gün tutsun dedik. | ||
RefreshTokenUsage = TokenUsage.ReUse | ||
} | ||
}; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
Microservices/IdentityServer/FreeCourse.IdentityServer/Controllers/UserController.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,60 @@ | ||
using FreeCourse.IdentityServer.Dtos; | ||
using FreeCourse.IdentityServer.Models; | ||
using FreeCourse.Shared.Dtos; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Identity; | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.IdentityModel.JsonWebTokens; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using static IdentityServer4.IdentityServerConstants; | ||
|
||
namespace FreeCourse.IdentityServer.Controllers | ||
{ | ||
[Authorize(LocalApi.PolicyName)] | ||
[Route("api/[controller]/[action]")] | ||
[ApiController] | ||
public class UserController : ControllerBase | ||
{ | ||
private readonly UserManager<ApplicationUser> _userManager; | ||
|
||
public UserController(UserManager<ApplicationUser> userManager) | ||
{ | ||
_userManager = userManager; | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> SignUp(SignupDto signupDto) | ||
{ | ||
var user = new ApplicationUser | ||
{ | ||
UserName = signupDto.Username, | ||
Email = signupDto.Email, | ||
City = signupDto.City, | ||
}; | ||
var result = await _userManager.CreateAsync(user, signupDto.Password); | ||
if (!result.Succeeded) | ||
{ | ||
return BadRequest(Response<NoContent>.Fail(result.Errors.Select(x => x.Description).ToList(), 400)); | ||
} | ||
return NoContent(); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> GetUser() | ||
{ | ||
var userClaim = User.Claims.FirstOrDefault(x => x.Type == JwtRegisteredClaimNames.Sub); | ||
if (userClaim is null) | ||
{ | ||
return BadRequest(); | ||
} | ||
var user = await _userManager.FindByIdAsync(userClaim.Value); | ||
if (user is null) | ||
{ | ||
return BadRequest(); | ||
} | ||
return Ok(new { Id = user.Id, UserName = user.UserName, Email = user.Email, City=user.City}); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Microservices/IdentityServer/FreeCourse.IdentityServer/Data/ApplicationDbContext.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,22 @@ | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore; | ||
using FreeCourse.IdentityServer.Models; | ||
|
||
namespace FreeCourse.IdentityServer.Data | ||
{ | ||
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> | ||
{ | ||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) | ||
: base(options) | ||
{ | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder builder) | ||
{ | ||
base.OnModelCreating(builder); | ||
// Customize the ASP.NET Identity model and override the defaults if needed. | ||
// For example, you can rename the ASP.NET Identity table names and more. | ||
// Add your customizations after calling base.OnModelCreating(builder); | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Microservices/IdentityServer/FreeCourse.IdentityServer/Dtos/SignupDto.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,10 @@ | ||
namespace FreeCourse.IdentityServer.Dtos | ||
{ | ||
public class SignupDto | ||
{ | ||
public string Email { get; set; } | ||
public string Username { get; set; } | ||
public string Password { get; set; } | ||
public string City { get; set; } | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Microservices/IdentityServer/FreeCourse.IdentityServer/FreeCourse.IdentityServer.csproj
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,44 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.0.0" /> | ||
|
||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="3.1.5" /> | ||
|
||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" /> | ||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" /> | ||
|
||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.5" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.5" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.5"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
|
||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.5" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.5" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Shared\FreeCourse.Shared\FreeCourse.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="Properties\Resources.Designer.cs"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.