Skip to content

Commit

Permalink
Merge pull request #11 from cloudscribe/vue-contrib
Browse files Browse the repository at this point in the history
merge Vue sample for #2
  • Loading branch information
joeaudette authored Apr 21, 2018
2 parents dae1ed3 + beb32f7 commit 837f361
Show file tree
Hide file tree
Showing 47 changed files with 1,300 additions and 5 deletions.
2 changes: 1 addition & 1 deletion OPServer/Config/IdentityServerIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ out bool didSetupIdServer
//customization
// not sure these are needed, need to comment out and test xamarin app
//services.AddTransient<ICorsPolicyService, IdServerCorsPolicy>();
services.AddTransient<IRedirectUriValidator, IdServerRedirectValidator>();
//services.AddTransient<IRedirectUriValidator, IdServerRedirectValidator>();

var idsBuilder = services.AddIdentityServerConfiguredForCloudscribe(options =>
{
Expand Down
3 changes: 2 additions & 1 deletion OPServer/OPServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
<PackageReference Include="cloudscribe.Core.Storage.NoDb" Version="2.0.6" />
<PackageReference Include="cloudscribe.Logging.NoDb" Version="2.1.1" />
<PackageReference Include="cloudscribe.Logging.Web" Version="2.1.2" />
<PackageReference Include="cloudscribe.Web.Localization" Version="2.0.0" />

<PackageReference Include="cloudscribe.Web.Localization" Version="2.0.*" />

<PackageReference Include="cloudscribe.Core.IdentityServerIntegration.Mvc" Version="2.1.14" />
<PackageReference Include="cloudscribe.Core.IdentityServer.NoDb" Version="2.1.2" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"ApiSecrets":[{"Description":null,"Value":"K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols=","Expiration":null,"Type":"SharedSecret"}],"Scopes":[{"Name":"api1","DisplayName":"api1","Description":"api1","Required":false,"Emphasize":false,"ShowInDiscoveryDocument":false,"UserClaims":[]}],"Enabled":true,"Name":"api1","DisplayName":"api1","Description":null,"UserClaims":["role"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Enabled":true,"ClientId":"vuejs","ProtocolType":"oidc","ClientSecrets":[],"RequireClientSecret":true,"ClientName":"vuejs","ClientUri":null,"LogoUri":null,"RequireConsent":true,"AllowRememberConsent":true,"AllowedGrantTypes":["implicit"],"RequirePkce":false,"AllowPlainTextPkce":false,"AllowAccessTokensViaBrowser":true,"RedirectUris":["http://localhost:5900"],"PostLogoutRedirectUris":["http://localhost:5900"],"FrontChannelLogoutUri":null,"FrontChannelLogoutSessionRequired":true,"BackChannelLogoutUri":null,"BackChannelLogoutSessionRequired":false,"AllowOfflineAccess":false,"AllowedScopes":["profile","openid","email","api1"],"AlwaysIncludeUserClaimsInIdToken":false,"IdentityTokenLifetime":300,"AccessTokenLifetime":3600,"AuthorizationCodeLifetime":300,"AbsoluteRefreshTokenLifetime":2592000,"SlidingRefreshTokenLifetime":1296000,"ConsentLifetime":null,"RefreshTokenUsage":0,"UpdateAccessTokenClaimsOnRefresh":false,"RefreshTokenExpiration":0,"AccessTokenType":0,"EnableLocalLogin":true,"IdentityProviderRestrictions":[],"IncludeJwtId":false,"Claims":[],"AlwaysSendClientClaims":false,"ClientClaimsPrefix":"client_","PairWiseSubjectSalt":null,"AllowedCorsOrigins":["http://localhost:5900"],"Properties":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Id":"9aca391e-e515-4520-9308-cf20b27750b3","Key":"KZEUHjNwWQFSY0wB49bNJVUEvjYvUg8u9oiyXrVVrYs=","Type":"user_consent","SubjectId":"19d0f112-34ef-4266-b1b4-d9c2ead8349a","ClientId":"vuejs","CreationTime":"2018-04-16T16:02:17Z","Expiration":null,"Data":"{\"SubjectId\":\"19d0f112-34ef-4266-b1b4-d9c2ead8349a\",\"ClientId\":\"vuejs\",\"Scopes\":[\"openid\",\"profile\",\"api1\"],\"CreationTime\":\"2018-04-16T16:02:17Z\",\"Expiration\":null}"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"AuthorBio":"","Comment":"","NormalizedEmail":"[email protected]","NormalizedUserName":"ADMIN","EmailConfirmed":true,"EmailConfirmSentUtc":null,"AgreementAcceptedUtc":null,"LockoutEndDateUtc":null,"NewEmail":"","NewEmailApproved":false,"LastPasswordChangeUtc":"2017-08-27T13:08:47.4368302Z","MustChangePwd":false,"PasswordHash":"AQAAAAEAACcQAAAAELsEmNPOTbhrsV8v+siQO9rtzlXkj3QvNVDtlaLZuo0XKTvKKlHx1ZCKgd/xnX4UuA==","CanAutoLockout":false,"AccessFailedCount":0,"RolesChanged":false,"SecurityStamp":"3687b9b5-4aed-447d-a674-cf1d5edc0a87","Signature":"","TwoFactorEnabled":false,"Id":"19d0f112-34ef-4266-b1b4-d9c2ead8349a","SiteId":"9c1cd70e-455c-43e6-b7f4-bb4ed60cf70c","Email":"[email protected]","UserName":"admin","DisplayName":"Admin","FirstName":"","LastName":"","IsDeleted":false,"Trusted":false,"AvatarUrl":"","DateOfBirth":null,"CreatedUtc":"2017-08-23T19:27:35.0835603Z","LastModifiedUtc":"2017-08-23T19:27:35.0835607Z","DisplayInMemberList":true,"Gender":"","IsLockedOut":false,"LastLoginUtc":"2018-04-11T19:02:49.9303707Z","PhoneNumber":"","PhoneNumberConfirmed":false,"AccountApproved":true,"TimeZoneId":"","WebSiteUrl":""}
{"AuthorBio":"","Comment":"","NormalizedEmail":"[email protected]","NormalizedUserName":"ADMIN","EmailConfirmed":true,"EmailConfirmSentUtc":null,"AgreementAcceptedUtc":null,"LockoutEndDateUtc":null,"NewEmail":"","NewEmailApproved":false,"LastPasswordChangeUtc":"2017-08-27T13:08:47.4368302Z","MustChangePwd":false,"PasswordHash":"AQAAAAEAACcQAAAAELsEmNPOTbhrsV8v+siQO9rtzlXkj3QvNVDtlaLZuo0XKTvKKlHx1ZCKgd/xnX4UuA==","CanAutoLockout":false,"AccessFailedCount":0,"RolesChanged":false,"SecurityStamp":"3687b9b5-4aed-447d-a674-cf1d5edc0a87","Signature":"","TwoFactorEnabled":false,"Id":"19d0f112-34ef-4266-b1b4-d9c2ead8349a","SiteId":"9c1cd70e-455c-43e6-b7f4-bb4ed60cf70c","Email":"[email protected]","UserName":"admin","DisplayName":"Admin","FirstName":"","LastName":"","IsDeleted":false,"Trusted":false,"AvatarUrl":"","DateOfBirth":null,"CreatedUtc":"2017-08-23T19:27:35.0835603Z","LastModifiedUtc":"2017-08-23T19:27:35.0835607Z","DisplayInMemberList":true,"Gender":"","IsLockedOut":false,"LastLoginUtc":"2018-04-21T12:34:12.4164807Z","PhoneNumber":"","PhoneNumberConfirmed":false,"AccountApproved":true,"TimeZoneId":"","WebSiteUrl":""}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ If you are new to cloudscribe please see the [Introduction](https://www.cloudscr
[![Build Status](https://travis-ci.org/cloudscribe/sample-idserver.svg?branch=master)](https://travis-ci.org/cloudscribe/sample-idserver)


# Using cloudscribe Core with IdentityServer4 and NoDb
# Using cloudscribe Core with IdentityServer4

cloudscribe Core and IdentityServer4 integration provides a compelling solution that makes it easy to provision new OP (OpenId Connect Provider) Servers each with their own Users, Roles, Claims, Clients, and Scopes. It includes a UI for managing all the needed data including role and claim assignments for users.
cloudscribe Core and IdentityServer4 integration provides a compelling solution that makes it easy to provision new OpenId Connect Provider server endpoints each with their own Users, Roles, Claims, Clients, and Scopes. It includes a UI for managing all the needed data including role and claim assignments for users, api resources, identity resources and api clients.

There are 2 mutually exclusive multi-tenancy configuration options. Tenants can be based on host names, or tenants can be based on the first folder segment of the url. This sample uses the folder segment approach. Folder tenants eare easier to provision than host name tenants because there are no additional DNS records needed and no additional SSL certificate is needed, you create new tenants from the UI and they work immediately.

Expand Down
24 changes: 24 additions & 0 deletions Tenant1Api/Controllers/IdentityController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Api.Controllers
{
[Route("api/[controller]")]
[Authorize]
public class IdentityController : ControllerBase
{

public IdentityController()
{
}
[HttpGet()]
public IActionResult Get()
{
return new JsonResult(from c in User.Claims select new { c.Type, c.Value });
}
}
}
24 changes: 24 additions & 0 deletions Tenant1Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Api
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
28 changes: 28 additions & 0 deletions Tenant1Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5901",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HTTPS_PORT": "5901"
}
},
"Api": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5901"
}
}
}
}
51 changes: 51 additions & 0 deletions Tenant1Api/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using IdentityServer4.AccessTokenValidation;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Api
{
public class Startup
{
public IConfiguration Configuration { get; }
public IHostingEnvironment Environment { get; }
public Startup(IConfiguration configuration, IHostingEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvcCore()
.AddJsonFormatters()
.AddAuthorization()
;

services.AddCors();

services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
.AddIdentityServerAuthentication(options =>
{
options.Authority = "http://localhost:50405" ;
options.RequireHttpsMetadata = false;
options.ApiName = "api1";
options.ApiSecret = "secret";
});

}

public void Configure(IApplicationBuilder app)
{
app.UseCors(policy =>
{
policy.AllowAnyOrigin();
policy.AllowAnyHeader();
policy.AllowAnyMethod();
});
app.UseAuthentication();
app.UseMvc();
}
}
}
22 changes: 22 additions & 0 deletions Tenant1Api/Tenant1Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="wwwroot\**" />
<Content Remove="wwwroot\**" />
<EmbeddedResource Remove="wwwroot\**" />
<None Remove="wwwroot\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions Tenant1Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
}
}
8 changes: 8 additions & 0 deletions Tenant1SpaVueJs/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": ["es2015", "stage-2"],
"plugins": [
"transform-runtime",
"transform-async-to-generator"
],
"comments": false
}
9 changes: 9 additions & 0 deletions Tenant1SpaVueJs/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
22 changes: 22 additions & 0 deletions Tenant1SpaVueJs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
// https://github.com/feross/standard/blob/master/RULES.md#javascript-standard-style
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow paren-less arrow functions
'arrow-parens': 0,
// allow async-await
'generator-star-spacing': 0,
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
Loading

0 comments on commit 837f361

Please sign in to comment.