Preauth API failing but check and ping are good


#1

Hi Team,

I reffed to https://duo.com/docs/authapi#endpoints to use DUO Auth API for check and preauth.
i used this https://github.com/duosecurity/duo_client_java/blob/master/duo-client/src/main/java/com/duosecurity/client/Http.java and with this the ping and check API’ are success but Preauth api i am getting 40103 Invalid signature in request credentials and i am using the correct ikey and skey that are created for Auth API in duo admin console

Could you please suggest me on how to resolve this issue.

Thank you


#2

Per this Duo KB article, please try the following suggestions:

Verify that the signature is encoded in hexadecimal ASCII; is using the correct HMAC-SHA1 signature as the password; lists parameters in alphabetical order.


#3

@DuoKristina what exactly does that mean? I’m using Postman simply to test and I’m receiving the same error.


#4

Hey @humblecoder,

Did you take a look at the KB article I referenced, which lists common Duo error codes and possible causes?


#5

@DuoKristina I did indeed. In fact I’d seen it before coming here. I don’t mean to be obtuse, but are you referring to the parameter structure as a “signature”? I’ve never seen “signature” in that context and have no idea how it’s being used.

Also, while the KB article ostensibly says what the fix is, it doesn’t make clear how that is accomplished. I mean, from my perspective, I’m sending the request in plain text via PostMan. I can’t imagine what else to fix.

Regards


#6

By “signature” we do refer to the computed SHA1 of the API request (with parameters) as described in here: Auth API | Duo Security.

Are you also having a success on /check but fail on /preauth? Or, is nothing successful?


#7

@DuoKristina Actually, I can’t get anything to succeed. Here is the JS I’m using to create the relevant params in PostMan:

	let curDate = (new Date()).toUTCString()
	let myHost = 'HIDDEN-HOST'

	let params = {
			'device': 'auto',
			'factor': 'push',
			'username': 'HIDDEN-NAME'
	}

	let urlEncodedParams = []

	_.forOwn(params,(v,k)=>{
		urlEncodedParams.push(encodeURIComponent(k) + '=' + encodeURIComponent(v))
	})

	let sigComponents = {
			'date': curDate,
			'host': myHost,
			'method': 'POST',
			'path': '/auth/v2/auth',
			'urlParam': urlEncodedParams.join('&')
	}

	let ■■■■ing = Object.values(sigComponents).join('\r\n')

	let hmacSignature = CryptoJS.HmacSHA1(sigComponentValueString, 'HIDDEN-STRING').toString()

	pm.environment.set("env_new_date", curDate)
	pm.environment.set("env_hmac_signature", hmacSignature);

	console.log(sigComponentValueString)

Obviously a convoluted process (especially given the nature of the requirement), but is there anything glaringly wrong.


#8

@DuoKristina It would be nice to have far more descriptive errors, especially in “development”. Perhaps we could see on our dashboard what was sent vs what the server compared it to.