Authenticating DotNetNuke Users in ColdFusion

后端 未结 3 672
深忆病人
深忆病人 2020-12-19 18:20

Is there any way to authenticate users from other web apps using the DNN logins?

We have a main site that is using DNN and user logins are stored in the asp net mem

3条回答
  •  梦毁少年i
    2020-12-19 18:51

    (Edit: Original answer did not work in all cases. Substantially revised ...)

    From what I have read, DNN uses an "SHA1" hash by default. The thread @barnyr posted shows it simply hashes the concatenated salt and password, but with a few twists.

    • DNN uses UTF-16LE to extract the password bytes, rather than CF's typical UTF-8.
    • It also extracts the salt and password bytes separately, which may produce different results than just decoding everything as a single string, which is what hash() does. (See demo below)

    Given that CF9's Hash function does not accept binary (supported in CF11), I do not think it is possible to duplicate the results with native CF functions alone. Instead I would suggest decoding the strings into binary, then using java directly:

    Code:

    
        thePassword = "DT!@12";
        base64Salt = "+muo6gAmjvvyy5doTdjyaA==";
    
        // extract bytes of the salt and password
        saltBytes = binaryDecode(base64Salt, "base64");
        passBytes = charsetDecode(thePassword, "UTF-16LE" );
    
        // next combine the bytes. note, the returned arrays are immutable, 
        // so we cannot use the standard CF tricks to merge them    
        ArrayUtils = createObject("java", "org.apache.commons.lang.ArrayUtils");
        dataBytes = ArrayUtils.addAll( saltBytes, passBytes );
    
        // hash binary using java
        MessageDigest = createObject("java", "java.security.MessageDigest").getInstance("SHA-1");
        MessageDigest.update(dataBytes);    
        theBase64Hash = binaryEncode(MessageDigest.digest(), "base64");
    
        WriteOutput("theBase64Hash= "& theBase64Hash &"
    ");


    Demo of Differences:

    
        theEncoding = "UTF-16LE";
        thePassword = "DT!@12";
        base64Salt = "+muo6gAmjvvyy5doTdjyaA==";
    
        // extract the bytes SEPARATELY
        saltBytes = binaryDecode(base64Salt, "base64");
        passBytes = charsetDecode(thePassword, theEncoding );
        ArrayUtils = createObject("java", "org.apache.commons.lang.ArrayUtils");
        separateBytes = ArrayUtils.addAll( saltBytes, passBytes );
    
        // concatenate first, THEN extract the bytes 
        theSalt = charsetEncode( binaryDecode(base64Salt, "base64"), theEncoding );
        concatenatedBytes = charsetDecode( theSalt & thePassword, theEncoding );
    
        // these are the raw bytes BEFORE hashing
        WriteOutput("separateBytes= "& arrayToList(separateBytes, "|") &"
    "); WriteOutput("concatenatedBytes"& arrayToList(concatenatedBytes, "|") );


    Results:

    separateBytes     = -6|107|-88|-22|0|38|-114|-5|-14|-53|-105|104|77|-40|-14|104|68|0|84|0|33|0|64|0|49|0|50|0
    concatenatedBytes = -6|107|-88|-22|0|38|-114|-5|-14|-53|-105|104|-3|-1|68|0|84|0|33|0|64|0|49|0|50|0 
    


提交回复
热议问题