damienbod / aspnetcoreangularsignalrsecurity Goto Github PK
View Code? Open in Web Editor NEWSecurity with ASP.NET Core, SignalR and Angular
License: MIT License
Security with ASP.NET Core, SignalR and Angular
License: MIT License
Hi There,
Sorry to be hammering you on this repo.
Is there some command that one must run so that webpack will watch for changes and update the app?
I have run the application from visual studio, did not use a task runner or anything. Just ran it using Control F5, and it runs fine, but when you make a change, shut down, re-run it is delivering up the previous code and not the stuff I have changed.
So.... something is wrong. When I go to the task runner in visual studio 2017 I see the Watch - Development task, I try to run it but get this error
Is there something I am missing?
I'm getting the following error with testing out your app, the error from google chrome console.
While it asking me to npm rebuild node-sass
, but when i look in the package.json. I don't even see this command.
index.js:1789 Uncaught Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Missing binding C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\node-sass\vendor\win32-x64-72\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 12.x
Found bindings for the following environments:
- Windows 64-bit with Node.js 10.x
This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
at module.exports (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\node-sass\lib\binding.js:15:13)
at Object.<anonymous> (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\v8-compile-cache\v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\v8-compile-cache\v8-compile-cache.js:161:20)
at getDefaultSassImpl (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\sass-loader\dist\index.js:198:10)
at Object.loader (C:\Users\sarin\source\repos\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\node_modules\sass-loader\dist\index.js:80:29)
at Object../node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./angularApp/styles.scss (https://localhost:44311/dist/app.bundle.js:98497:7)
at __webpack_require__ (https://localhost:44311/dist/app.bundle.js:20:30)
at Object../angularApp/styles.scss (https://localhost:44311/dist/app.bundle.js:12199:15)
at __webpack_require__ (https://localhost:44311/dist/app.bundle.js:20:30)
at Module../angularApp/main.ts (https://localhost:44311/dist/app.bundle.js:240:14)
at __webpack_require__ (https://localhost:44311/dist/app.bundle.js:20:30)
at https://localhost:44311/dist/app.bundle.js:84:18
at https://localhost:44311/dist/app.bundle.js:87:10
Maybe to better to understand the enviroment
PS C:\> npm -v
6.13.4
PS C:\> node -v
v12.4.0
PS C:\> ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.1.1
Node: 12.4.0
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.801.1
@angular-devkit/core 8.1.1
@angular-devkit/schematics 8.1.1
@schematics/angular 8.1.1
@schematics/update 0.801.1
rxjs 6.4.0
Hi,
I m trying to understand how SignalR works with Authentication, so thanks for your work, it s helpful.
About this page:
https://github.com/damienbod/AspNetCoreAngularSignalRSecurity/blob/master/DirectMessagesAngular/angularApp/app/directmessages/directmessages.service.ts
I read that you can use this instead:
this._hubConnection = builder.withUrl(
environment.apiUrl + '/hubs/notification',
{ accessTokenFactory: () => `bearer ${myToken}` }
).build();
So the code in startup (https://github.com/damienbod/AspNetCoreAngularSignalRSecurity/blob/master/ApiServer/Startup.cs) will be updated to:
context.HttpContext.Request.Headers.TryGetValue("Authorization", out var accessToken)
instead of
context.Request.Query.TryGetValue("token", out StringValues token)
I read other thing too, about IUserIdProvider, in startup:
services.AddSignalR();
services.AddSingleton<IUserIdProvider, UserIdProvider>();
and UserIdProvider
public class UserIdProvider : IUserIdProvider
{
private readonly IUserManager _userManager;
public UserIdProvider(IUserManager userManager)
{
_userManager = userManager;
}
public string GetUserId(HubConnectionContext connection)
{
return string.Empty;
}
}
What I was expecting with the variable connection
is to see information about the user. We have set [Authorize] to the Hub, means it uses the authentication process, so, in my mind, i m supposed to receive name and role:
Here is how the Token is generated:
var tokenDescriptor = new SecurityTokenDescriptor
{
Issuer = authSettings.Issuer,
Audience = authSettings.Audience,
NotBefore = DateTime.UtcNow,
IssuedAt = DateTime.UtcNow,
Subject = new ClaimsIdentity(new Claim[]
{
new Claim(Constants.ClaimTypes.Sid, user.Id.ToString()), //Currently there an issue with ClaimTypes.Sid which not generate 'sid' (https://github.com/dotnet/corefx/issues/28454)
new Claim(ClaimTypes.Name, user.Id.ToString()),
new Claim(ClaimTypes.Role, user.RoleName),
}),
Expires = token.ExpirationDate,
SigningCredentials = GenerateSigningCredentials(authSettings.SecretKey)
};
This post is not really an Issue, more a discussion, I hope you will be interested to talk about it :).
Is there a theoretical possibility to log in from the SPA application on a stand alone IdentityServer without redirect?
Hi Damo,
This sample looks great, but having ALOT of trouble trying to get the angular app to build and run.
Task runner fires up, but just has errors, and nothing helpful. this is what happens when I hit start from the task runner in VS 2017 on the SignalR project
I find your Angular setups just dont work for me. Im getting around this these days by using Angular-CLI and copy pasting your stuff into that. Angular-CLI just works.
Anyway, here is the errors I am getting from the task runner. Am I not supposed to use the task runner in VS 2017? Am I supposed to run something from CMD window?
yarn run v1.3.2
$ concurrently "webpack-dev-server --env=dev --open --hot --inline --port 8080" "dotnet run"
[0] @@@@@@@@@ USING DEVELOPMENT @@@@@@@@@@@@@@@
[0] clean-webpack-plugin: C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\wwwroot\dist has been removed.
[0] clean-webpack-plugin: C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\wwwroot\assets has been removed.
[0] Project is running at http://localhost:8080/
[0] webpack output is served from /
[0] Content not from webpack is served from C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\wwwroot
[0] 404s will fallback to /index.html
[0] webpack: wait until bundle finished: /
[0]
[0] Could not find implementations for the following rules specified in the configuration:
[0] no-access-missing-member
[0] templates-use-public
[0] invoke-injectable
[0] Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
[0] If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.
[0]
[0] Warning: The 'no-use-before-declare' rule requires type information.
[0]
[0] [at-loader] Using [email protected] from typescript and "tsconfig.json" from C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR/tsconfig.json.
[0]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 1 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 2 in 1000
[1] ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 7 in 1000
[1] ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\Securit
[1] yAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 9 in 1000
[1] ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\Securit
[1] yAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Beginning retry 10 in 100
[1] 0ms. The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): error MSB3027: Could not copy "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". Exceeded retry count of 10. Failed. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1] C:\Program Files\dotnet\sdk\2.0.3\Microsoft.Common.CurrentVersion.targets(4052,5): error MSB3021: Unable to copy file "obj\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll" to "bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll". The process cannot access the file 'C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\bin\Debug\netcoreapp2.0\SecurityAspNetCoreSignalR.dll' because it is being used by another process. [C:\test\AspNetCoreAngularSignalRSecurity\SecurityAspNetCoreSignalR\SecurityAspNetCoreSignalR.csproj]
[1]
[1] The build failed. Please fix the build errors and run again.
[1]
[1] dotnet run exited with code 1
Is there special instructions for this? Ive tried all sorts of things
cheers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.