Skip to content

01. Getting Started

Luke Girvin edited this page Dec 13, 2019 · 5 revisions

In your own OWIN application, you may want to map a path to the SCIM server endpoints like shown below:

appBuilder.Map("/scim", app =>
{
    app.UseScimServer(configuration => { 
        configuration.RequireSsl = false; // disable SSL requirements
        configuration.EnableEndpointAuthorization = false; // disable authentication requirements
    });
});

UseScimServer()

Owin.Scim makes use of MEF during initial application composition. Furthermore, the library is dependent upon an application composition framework called NContext. NContext is an open source library released under the MIT license and available on GitHub and Nuget. Its core architectural principles are centered around MEF and therefore, it's important to understand the basics around Owin.Scim's composition architecture.

The above code will create a new SCIM server using the Assembly.GetCallingAssembly().Location as a file to include in composition. If you have other SCIM-related assemblies, there is a more customizable UseScimServer() method overload.

Specifying File Composition Constraints

appBuilder.Map("/scim", app =>
{
    app.UseScimServer(
        new Predicate<FileInfo>[] { fileInfo => fileInfo.Name.Equals("YourProjectName") },
        configuration => { 
            configuration.RequireSsl = false;
            configuration.EnableEndpointAuthorization = false; 
    });
});

File Composition Constraints

When invoking UseScimServer in your IAppBuilder pipeline, you're asked to specify an argument called fileCompositionConstraints. This IEnumerable<Predicate<FileInfo>> represents a (SQL)WHERE-style predicate that NContext will use to build a MEF CompositionCatalog. If you're not familiar with MEF, that's okay and not important. What you must be aware of, however, is that Owin.Scim needs to know in what assemblies it should look for SCIM-related functionality.

For instance, Owin.Scim will always contain a composition constraint that looks like:

fileInfo => 
fileInfo.Name.StartsWith("Owin.Scim", StringComparison.OrdinalIgnoreCase) && 
new[] { ".dll" }.Contains(fileInfo.Extension.ToLower())

Owin.Scim will use this information to reflect all assemblies which satisfy the predicate(s) defined. This reflection process is only done once, in a thread-safe manner during application composition (ie. within the composition root of your application.)

Depending on your application type; whether a console app, service, web-application, etc, you typically import Owin.Scim as a nuget package. Your main project may be a .dll or .exe with your own project name. For an example, please look at our /samples provided.

Samples/ConsoleHost

Take a look at this sample application and look at the file called CompositionRoot.

app.UseScimServer(
  new Predicate<FileInfo>[] {
      fileInfo => fileInfo.Name.Equals("ConsoleHost.exe", StringComparison.OrdinalIgnoreCase)
  },
  configuration => { 
      configuration.RequireSsl = false; // disable SSL requirements
      configuration.EnableEndpointAuthorization = false; // disable authentication requirements
  });

As you can see, our project is an executable named ConsoleHost.exe. Since we have our own SCIM user / group repositories we'll want to use and register with Owin.Scim, we MUST add a predicate to tell Owin.Scim where these types exist. If we have any additional .dll libraries we can add predicates for those as well. To further illustrate this and provide you context around why this is required we'll explore how to register your own SCIM repositories and/or override Owin.Scim's default services to provide you a powerful extensibility experience.

Clone this wiki locally