Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Writing your own authorization plugins

Ryan Newington edited this page Jan 9, 2020 · 1 revision

Version 2 of the LAPS web app allows you to write your own authorization plugins using C#.

You can replace any of the interfaces shown below with your own implementation.

The following web.config changes need to be made to load your plugin.

Add a new unity <section> item to the <configSections> element

  <configSections>
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Unity.Configuration" />
    <section name="lithnet-laps" type="Lithnet.Laps.Web.LapsConfigSection" />
    <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
  </configSections>

Add the <unity> element, and swap out the mapTo with your own class and assembly names

  <unity>
    <container>
      <register type="Lithnet.Laps.Web.Security.Authorization.IAuthorizationService, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Security.Authorization.ConfigurationFile.ConfigurationFileAuthorizationService, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Models.IDirectory, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.ActiveDirectory.ActiveDirectory, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Security.Authentication.IAuthenticationService, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Security.Authentication.AuthenticationService, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Security.Authorization.IAvailableTargets, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Security.Authorization.AvailableTargets, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Security.Authorization.ConfigurationFile.IAvailableReaders, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Security.Authorization.ConfigurationFile.AvailableReaders, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Audit.IReporting, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Audit.Reporting, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Audit.ITemplates, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Audit.TemplatesFromFiles, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.IRateLimiter, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.RateLimiter, Lithnet.Laps.Web" />
      <register type="Lithnet.Laps.Web.Mail.IMailer, Lithnet.Laps.Web" mapTo="Lithnet.Laps.Web.Mail.SmtpMailer, Lithnet.Laps.Web" />
    </container>
  </unity>