spa-template | NET Core / React / Redux / TypeScript - Starter | Frontend Framework library
kandi X-RAY | spa-template Summary
kandi X-RAY | spa-template Summary
This template was originally created in 2017 and used cutting edge technologies at that time - .NET Core, React, Typescript, Webpack, Docker. As time passes and more projects added - common parts of the template were separated into it's own libraries that we call Mocoding Stack:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spa-template
spa-template Key Features
spa-template Examples and Code Snippets
Community Discussions
Trending Discussions on spa-template
QUESTION
TL;DR
How can I delegate my user permissions to a service principal in Azure Ad when the usual interactive
way (e.g. web app with consent screen popup) is not feasible? This is because I cannot configure the MSI in the Azure Portal properly to work that way.
More detail
I want to grant an application permission to access the Graph API on behalf of a user. Usually, this is a well-documented scenario in which you create an app registration, acquire delegated user permissions
by asking permission for the needed scopes, and then use these permissions in the app.
The app that needs Graph access is a background service that is to work on its own without user intervention/activity. For this use case, the common approach is to use application permissions
. In my case this is not feasible, because application permissions require admin-consent and are all-or-nothing kind of permissions. There is no way this will be granted for me. Rightfully so, because its overkill.
But on the other hand that's really a pity. A pity, because I've found an example on how to assign Graph API application permissions directly to a Managed Service Identity
rather than to a self-registered app. And my service (as an Azure Functions app) already has a MSI assigned to it. So this would be the perfect fit, b then again, there is no way I'll get those application permissions.
So what is the workaround? We have this one user principal
which has all the required permissions we need for our background service. What I want to do is to delegate this user's permissions to the Function App/MSI. In order to do this, I used this SPA-template by the MSAL team to have something that will prompt me the permissions popup.
This however failed because the implicit oauth flow
was not enabled. To remedy this, you usually need to update the app manifest in the portal. However, since this is a MANAGED service identity, and not a self-registered one, the MSI is not listed in the portal under app registrations. So I cannot set this property to true.
Doing the same via Azure CLI also failed because apparently the MSI is not identified as an app.
...ANSWER
Answered 2021-Feb-09 at 09:48In my experience Managed Identities don't support the scenario you are suggesting. They do not have an app registration and in that way cannot authenticate users interactively.
I would go with your fallback solution; a normal app registration and use that to access Graph API on behalf of the user. This is what we do in our projects at least. App permissions -> Managed Identity if possible. Delegated permissions -> normal app registration + secret/certificate in Key Vault, retrieved with Managed Identity.
QUESTION
I'm using ASP.NET Identity (Database First) in my ASP.NET MVC application. I followed the instructions here, to set up the ASP.NET Identity with database first approach.
My AspNetUsers table has a relationship with the Employee table (The Employee table has a UserId foreign key, and the AspNetUsers entity has an ICollection
property).
I would like to add the ICollection
property to the ApplicationUser, like below:
ANSWER
Answered 2018-Aug-24 at 16:31I cannot reproduce the issue, even when I create the tables in another database without keys and relations. So I'm sure that there is a problem with your model. Unfortunately you didn't add code which I can compare, so I can't tell what is different and answer the question directly. The only thing I can do is to show what works for me. However, first I have some remarks.
I think you shouldn't follow the article. As there is no reason to add the context to an existing database.
Like Ivan Stoev mentioned you are not supposed to mix contexts. The Identity context is meant to authenticate the user. It stores the credentials, the roles of the user and claims. Where claims are meant to add identity information about the user.
In fact, the default Hometown
field of the ApplicationUser template can be removed, as it is an identity claim which should be stored in the AspNetUserClaims table. Not something you need to extend the ApplicationUser for. Actually I can't think of any reason to extend the ApplicationUser.
About the roles, these are not really claims, as they tell nothing about the identity but rather are used for authorization. That's why it's fine that they are stored in the AspNetUserRoles table. Unfortunately roles are added to the identity as role claims, which makes things confusing.
Please note that the Identity information is present in the claims. This means that the application doesn't have to call the Identity context. E.g. User.IsInRole checks the role claims of the current identity, not the roles stored in the table.
About the different contexts, the other context (which I usually call the business model) has nothing in common with the Identity context. Email and other fields are not part, nor have meaning to the business model. You may think that those fields are redundant, but in fact they are not. I could login using a google account, but for the business use my work email address.
There are several reasons to keep the context seperated.
- Seperation of concerns. Suppose you want to exchange the authentication framework in the future with another one. Like implement IdentityServer in case you want to support single sign-on (SSO).
- You can't move the users table to another database if another application needs the same logins. So you'll end up adding other contexts as well to the database.
- Trouble with migrations. If you mix the contexts then migrations will fail.
- It'll makes things far more easier. This is the first problem you've encountered, not the last.
As also mentioned in the article:
At this point if you need to add any relationships (E.g. foreign keys) from your own tables to these tables you are welcome to do so but do not modify any of the Entity Framework 2.0 tables directly or later on any of their POCO classes. Doing so will result in errors based upon feedback I’ve received.
So how to manage the information if you shouldn't access the identity context from your application?
For the current user you don't need to access the users table. All the information is present in the identity claims. The only reason to access the identity context is to allow a user to login. Besides user management.
You can suffice by adding a reference to the user (the userid). If you need to show information of other users (like name) in a report, then create a user table in your business context to store the information. You can add relations to this table, as it is part of the same context.
Please let me know if you have questions about this approach.
Now the code that works for me. Like others have mentioned, it is not likely that adding the line:
QUESTION
I created a new .Net-Core Angular project following the wizard in VS2017, then I added a new constructor with a single param within the controller like this:
...ANSWER
Answered 2018-Nov-06 at 08:33When you remove the default constructor, the runtime will try to create an instance via the single-param-constructor. Then, most likely, the runtime don't know how to resolve the string dependency to create the controller.
Therefore, In your ConfigureServices method in Startup.cs, enable the registration of controllers as services and then register the dependency
QUESTION
I am attempting to use the bootstrap scss files instead of the css file so I can override the bootstrap variables. I can get the styles to load using the css file but not using scss files. I am doing so in a .NET Core Angular project created from the Visual Studio 2017 Angular template.
I have tried the answers here but have had no luck.
Spa template .net core 2.0 angular 4 webpack 2 use sass not boostrap 4 css
Here is my understanding of how it should work:
The webpack.config.vendor.js file generates vendor.js and vendor.css. I understand vendor.js is kept separate from main-client.js so that it only needs to be built when the vendor dependencies change, improving the build process and only doing cache busting when needed for production publishes.
In the scenario where I want to compile bootstrap's scss files instead of using their css files, I expect that the bootstrap.css reference in webpack.config.vendor.js should be REMOVED and instead a scss rule is added to webpack.config.js.
Webpack.config.js generates a main-client.js file that includes all the js code needed for the angular components. And by inluding the scss rule in the config, it should also compile the bootstrap scss files into styles that are injected in the html header via javascript.
A styles.scss file in my app is processed by webpack.config.js and should have @import "~bootstrap/scss/bootstrap" so that the bootstrap scss files are built. Ultimately I would also import my own _custom.scss file where I override the variables.
Is my understanding correct?
Also, I don't know what keeps webpack.config.js from processing the bootstrap scss files under the node-modules folder in addition to my style.scss file (which already imports bootstrap.scss). Is that something I need to define in webpack.js?
Here is my webpack.config.js. The scss rule is straight from the bootstrap documentation.
...ANSWER
Answered 2017-Dec-11 at 22:57Of course, as soon as I post the question, I figure it out.
The issue was that I needed to import the style.scss in my entry point module boot.browser.ts. Which also answers the question about how webpack knows to compile just the styles.scss and not all the bootstrap.scss files.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spa-template
Running the application
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page