1
votes

I'm currently implementing a solution consisting in ADFS 3.0 with multifactor authentication. I've followed the steps in TechNet (https://msdn.microsoft.com/en-GB/Library/dn783423.aspx?f=255&MSPPError=-2147217396) to setup the sample adapter, which works fine. I now want to extend it and have face a few issues. I've search the web and stackoverflow for something similar but couldn't find anything so I'm posting them all here. Not sure if I need to split this into different questions:

  1. I need to extend the adapter so that part of the html is rendered by an external script, i.e. I need to add an extra script to be loaded when the adfs adapter html is rendered. From what I could find, one could modify the Theme to include additional javascript in the onload.js, but I don't want to go down this road, since the script really needs to be loaded externally.

The only way I can think of, and kind of works, is to inject javascript in html that loads the script dinamically, something like this:

var script =document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", <my_script_loaded_over_http>)

fileref.onload =
        function() {
         //call script method
        };

But because the external script depends on the "onload" event of the window for some of it's logic, it doesn't work since it's loaded too late..

Is this possible at all?

  1. Is it possible for the adapter to inject new response headers? (I'm assuming it isn't)

  2. Is there a standard way to provide a configuration file to the adapter dll, so that some values can be changed at runtime without having to deploy a new dll? If not, is it safe to write the said configuration file to the adfs folder and read from there?

Thank you very much

1

1 Answers

1
votes

I managed to figure this out by myself:

1- The interface IAdapterPresentationForm provides a method to return whatever scripts or css I want to include: string GetFormPreRenderHtml(int lcid) e.g.:

 public string GetFormPreRenderHtml(int lcid){
        StringBuilder sb = new StringBuilder();
        sb.Append("<script src='http://myjs.js' type='text/javascript'></script>");
        sb.Append("<link rel='stylesheet' type='text/css' href='http://mycss.css' />");
        return sb.ToString();
 }

2- Not at all

3- It's possible to pass a configuration file when registering the adapter using: Register-AdfsAuthenticationProvider -TypeName $typeName -Name -Verbose -ConfigurationFilePath .

The pipeline will open a stream for you, and pass it in:

void OnAuthenticationPipelineLoad(IAuthenticationMethodConfigData configData)

Reference: http://blogs.recneps.net/category/ADFS