Certificate for Windows IoT Core Retail Image [on hold]

I am working on a Windows 10 IoT Core application and I need to build a custom retail image of Windows 10 IoT Core. I was following the docs of building retail image for Windows 10 IoT Core here(https://docs.microsoft.com/en-us/windows-hardware/manufacture/iot/build-retail-image#build-and-create-the-image).

There is a slight confusion whether I need a Code Signing certificate or a Driver signing certificate. I am quoting the important statement from official docs.

Purchase a code-signing certificate from a Certificate Authority (CA) for which Microsoft also issues a cross-certificate. The Cross-Certificates for Kernel Mode Code Signing topic provides a list of CAs for which Microsoft also provides cross-certificates and the corresponding cross-certificates. Note that these are the only cross-certificates that chain up to the “Microsoft Code Verification Root” issued by Microsoft, which will enable Windows to run OEM drivers.

So I am confused in Code Signing vs Driver Signing, Any help in this regard is highly appreciated.

Why do I define my Queries, Data, and Mutation as Singleton when using GraphQL in .NET Core?

Why do I define my Queries, Data, and Mutation as Singleton when using GraphQL in .NET Core?

From the doc’s dependency injection page:

public void ConfigureServices(IServiceCollection services) {   services.AddSingleton<IDependencyResolver>(s => new FuncDependencyResolver(s.GetRequiredService));    services.AddSingleton<IDocumentExecuter, DocumentExecuter>();   services.AddSingleton<IDocumentWriter, DocumentWriter>();    services.AddSingleton<StarWarsData>();   services.AddSingleton<StarWarsQuery>();   services.AddSingleton<StarWarsMutation>();   services.AddSingleton<HumanType>();   services.AddSingleton<HumanInputType>();   services.AddSingleton<DroidType>();   services.AddSingleton<CharacterInterface>();   services.AddSingleton<EpisodeEnum>();   services.AddSingleton<ISchema, StarWarsSchema>(); } 

At the beginning of the docs:

The library resolves a GraphType only once and caches that type for the lifetime of the Schema.

While I understand that these are more like DTOs in which they hold values or their class content doesn’t change at all… Why do I specify them as singleton instead of just letting them get instantiated?

Where to apply multi-tenant logic (ASP.Net Core)?

I’m developing a multi-teant SaaS application in ASP.NET core mvc and I was wondering what the general approach is to applying tenant logic in a shared database scenario (TenantId for each entity). And more specificly, where this logic should be applied; In the Context, UnitOfWork, Repository or Service?

My current architecture looks like this:

EF DbContext -> UnitOfWork -> Repository -> Service 

Right now, I’m applying all of my logic in the EF DbContext. For example applying the TenantId to a entity:

public override int SaveChanges( ) {     foreach ( var entityEntry in ChangeTracker.Entries( ) )     {         if ( entityEntry.Entity is ITenantEntity entity )         {             if ( entityEntry.State == EntityState.Added ||                  entityEntry.State == EntityState.Modified )             {                 entity.TenantId = _tenantProvider.GetTenantId( );             }         }     }      return base.SaveChanges( ); } 

And filtering out data based on tenant:

protected override void OnModelCreating( ModelBuilder builder ) {     base.OnModelCreating( builder );      ... omitted ....      builder.Entity<Person>( )         .HasQueryFilter( p => p.TenantId == _tenantProvider.GetTenantId( ) );      builder.Entity<Address>( )         .HasQueryFilter( p => p.TenantId == _tenantProvider.GetTenantId( ) );      builder.Entity<Company>( )         .HasQueryFilter( p => p.TenantId == _tenantProvider.GetTenantId( ) );      ... omitted .... } 

How does Drupal pass the values from the database to the templating system at the core level?

Drupal core working question!!. I know how to create a new Drupal theme but I am trying to go deeper.

I haven’t quite figured out how Drupal passes the values from the database or the backend to the theme variables in the template?

Which function does it use to disperse the variables to the corresponding template?

C# .Net Core API design – interfaces vs DTOs

I’m designing a relatively simple web application using .net core. I’ve mostly done desktop development in my career so far, so I’m a bit new to the nuances between desktop and web development.

In this application there is a business logic layer and a presentation logic layer which takes the business logic and transforms the properties into marked up output server-side and then returns the data to the client through a web API.

Due to the controls I’m using and the structure of the application, it makes sense to have this “presentation logic” layer on the server side, since some aspects of the presentation are actual business logic requirements (most of the presentation is handled in views, partial views and view components).

Currently the way that I am handling this is by injecting the business logic classes into presentation logic classes, then having the api controller return an interface to the presentation logic class.

A simplified example of the approach:

public class BusinessLogic {   public string PropertyA { get; set; }    public string PropertyB { get; set; }    public void DoSomeLogic() { // some code here } }  public class PresentationLogic : IPresented {   private BusinessLogic businessLogic;    public PresentationLogic(BusinessLogic businessLogic)   {     this.businessLogic = businessLogic;   }    public string PresentationPropertyA   {     get     {       return "<span class='businesslogicspecificclass'>" + this.businessLogic.PropertyA + "</span>";     }   } }  public interface IPresented {   string PresentationPropertyA { get; } }  [Route("api/[controller]")] public class MyController {   [HttpGet]   public IPresented Get()   {     var businessLogic = new BusinessLogic();     // manipulate businessLogic     return new PresentationLogic(businessLogic);   } } 

The API exposes interfaces which are implemented by the PresentationLogic classes. As I understand it, these interfaces are then serialised into JSON and returned to the page to use within its controls.

A different approach to solving the same problem would be to create a DTO, and have the PresentationLogic class take the business logic and spit out the DTO, adding the extra markup to the properties during the creation of the DTO. For example:

public class PresentationLogic {   public Dto GetDtoFromBusinessLogic(BusinessLogic businessLogic)   {     return new Dto { PresentationPropertyA = "<span class='businesslogicspecificclass'>" + this.businessLogic.PropertyA + "</span>" };   } }  public class Dto {   public PresentationPropertyA { get; set; } }  [Route("api/[controller]")] public class MyController {   [HttpGet]   public Dto Get()   {     var businessLogic = new BusinessLogic();     // manipulate businessLogic     var presentationLogic = new PresentationLogic();     return presentationLogic.GetDtoFromBusinessLogic(businessLogic);   } } 

What I want to know is what the advantages or disadvantages to each approach is.

As I understand it, both controller methods will return effectively the same JSON to the calling page.

The first approach feels more natural to me for the following reasons:

  • I do not like DTOs unless they’re absolutely necessary since I believe that they tend to encourage anaemic domain models
  • The presentation logic class becomes an adapter class that sits between the business logic and the view. It has a clearly defined responsibility.
  • I have not created any classes purely for the purpose of acting as a return type – it feels like less wasted code.
  • I could potentially add new properties to the PresentationLogic class and implement a new interface if version 2 called for changes.
  • Interfaces feel like the natural tool for abstraction for C# code.

I was discussing this with other developers and they were suggesting that returning a DTO was the more standard way of approaching this problem. I have come up with a couple of reasons why this might be a better approach:

  • DTOs are clearly marked as such and nobody is tempted to add breaking logic to them.
  • If it’s the standard way then it will help new developers to get up to speed.
  • Adding a new version forces the use of a new DTO class, which means that there’s less potential to introduce breaking changes (though this could also be done with the other approach if needed)

Note that this question is generally about layered web architecture than specifically about my needs on this project. If no presentation logic needed to be added server-side, this question could easily be about business logic and persistence logic classes.

So which is better – using DTOs in a web API or using interfaces on complex objects in a web API?

Concepts in Authentication and Identity modules in ASP.NET Core 2

I am really trying to get the big picture of the Authentication and Identity modules in ASP.NET Core 2: not just how to use them (which I can and which I do) but really what exactly are the different parts in the implementation and how they fit together in the big picture.

To be clear, I’ve read the Authentication section of the ASP.NET Core 2 documentation but it very rarely explains the big picture interactions or at least not in a very structured or clear manner.

I am looking for something that explains concepts like: What does ClaimsIdentity and ClaimsPrincipals mean and why use it that way not just a one-liner about how to use them.

Also what are Authentication Schemes, Sign In Schemes and Challenge Schemes, in fact what exactly is meant by scheme here? How exactly cookie authentication works (like I understand how to make it work but I don’t understand exactly what goes on behind the scenes and when?)

I hope I could explain myself well. I just feel that most of the documentation is about “do this and do” that without explaining the bigger picture and I feel I would be a lot more comfortable using these things and knowing what and when to customize these things with that knowledge with me.

Thanks!