/// <summary> /// https://duo.com/docs/authapi#/enroll /// </summary> /// <param name="username">Username for the created user. If not given, a random username will be assigned and returned.</param> /// <param name="valid_secs">Seconds for which the activation code will remain valid. Default: 86400 (one day).</param> public async Task <DuoResponse <EnrollResult> > EnrollAsync(string username = null, int?valid_secs = null) { var request = builder.EnrollRequest(username, valid_secs); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <EnrollResultModel, EnrollResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/check /// </summary> public async Task <DuoResponse <PingResult> > CheckAsync() { var request = builder.CheckRequest(); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <PingResultModel, PingResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="username">Unique identifier for the user that is commonly specified by your application during user creation (e.g. [email protected]). Exactly one of user_id and username must be specified.</param> /// <param name="device">ID of the device to call. This device must have the "phone" capability. You may also specify "auto" to use the first of the user's devices with the "phone" capability.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> public async Task <DuoResponse <AuthAsyncResult> > AuthPhoneByUsernameForPollingAsync(string username, string device = "auto", string ipaddr = null) { var request = builder.AuthRequest(null, username, "phone", ipaddr, "1", device, null); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthAsyncResultModel, AuthAsyncResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/auth_status /// </summary> /// <param name="txid">The transaction ID of the authentication attempt, as returned by the /auth endpoint.</param> public async Task <DuoResponse <AuthStatusResult> > AuthStatusAsync(string txid) { var request = builder.AuthStatusRequest(txid); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthStatusResultModel, AuthStatusResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="user_id">Permanent, unique identifier for the user as generated by Duo upon user creation (e.g. DUYHV6TJBC3O4RITS1WC). Exactly one of user_id and username must be specified.</param> /// <param name="device">ID of the device to send passcodes to. This device must have the "sms" capability. You may also specify "auto" to use the first of the user's devices with the "sms" capability.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> public async Task <DuoResponse <AuthResult> > AuthSmsByUserIdAsync(string user_id, string device = "auto", string ipaddr = null) { var request = builder.AuthRequest(user_id, null, "sms", ipaddr, null, device, null); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthResultModel, AuthResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="user_id">Permanent, unique identifier for the user as generated by Duo upon user creation (e.g. DUYHV6TJBC3O4RITS1WC). Exactly one of user_id and username must be specified.</param> /// <param name="passcode">Passcode entered by the user.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> public async Task <DuoResponse <AuthAsyncResult> > AuthPasscodeByUserIdForPollingAsync(string user_id, string passcode, string ipaddr = null) { var request = builder.AuthRequest(user_id, null, "passcode", ipaddr, "1", null, passcode); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthAsyncResultModel, AuthAsyncResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/preauth /// </summary> /// <param name="username">Unique identifier for the user that is commonly specified by your application during user creation (e.g. [email protected]). Exactly one of user_id and username must be specified.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> /// <param name="trusted_device_token">If the trusted_device_token is present and the Remembered Devices option is enabled in the Duo Admin Panel, return an "allow" response for the period of time a device may be remembered as set by the Duo administrator.</param> public async Task <DuoResponse <PreAuthResult> > PreAuthByUsernameAsync(string username, string ipaddr = null, string trusted_device_token = null) { var request = builder.PreAuthRequest(null, username, ipaddr, trusted_device_token); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <PreAuthResultModel, PreAuthResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="username">Unique identifier for the user that is commonly specified by your application during user creation (e.g. [email protected]). Exactly one of user_id and username must be specified.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> public async Task <DuoResponse <AuthResult> > AuthAutoByUsernameAsync(string username, string ipaddr = null) { var request = builder.AuthRequest(null, username, "auto", ipaddr, null, "auto", null); var response = await client.SendAsync(request).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthResultModel, AuthResult>(response)); }
/// <summary> /// https://duo.com/docs/authapi#/check /// </summary> /// <param name="cancelToken">Cancellation Token in case you want to cancel mid-request.</param> public async Task <DuoResponse <PingResult> > CheckAsync(CancellationToken cancelToken = default) { var request = builder.CheckRequest(); var response = await client.SendAsync(request, cancelToken).ConfigureAwait(false); return(await DuoResponse.ParseAsync <PingResultModel, PingResult>(response).ConfigureAwait(false)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="user_id">Permanent, unique identifier for the user as generated by Duo upon user creation (e.g. DUYHV6TJBC3O4RITS1WC). Exactly one of user_id and username must be specified.</param> /// <param name="device">ID of the device to call. This device must have the "phone" capability. You may also specify "auto" to use the first of the user's devices with the "phone" capability.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> /// <param name="cancelToken">Cancellation Token in case you want to cancel mid-request.</param> public async Task <DuoResponse <AuthAsyncResult> > AuthPhoneByUserIdForPollingAsync(string user_id, string device = "auto", string ipaddr = null, CancellationToken cancelToken = default) { var request = builder.AuthRequest(user_id, null, "phone", ipaddr, "1", device, null); var response = await client.SendAsync(request, cancelToken).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthAsyncResultModel, AuthAsyncResult>(response).ConfigureAwait(false)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="username">Unique identifier for the user that is commonly specified by your application during user creation (e.g. [email protected]). Exactly one of user_id and username must be specified.</param> /// <param name="passcode">Passcode entered by the user.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> /// <param name="cancelToken">Cancellation Token in case you want to cancel mid-request.</param> public async Task <DuoResponse <AuthAsyncResult> > AuthPasscodeByUsernameForPollingAsync(string username, string passcode, string ipaddr = null, CancellationToken cancelToken = default) { var request = builder.AuthRequest(null, username, "passcode", ipaddr, "1", null, passcode); var response = await client.SendAsync(request, cancelToken).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthAsyncResultModel, AuthAsyncResult>(response).ConfigureAwait(false)); }
/// <summary> /// https://duo.com/docs/authapi#/auth /// </summary> /// <param name="username">Unique identifier for the user that is commonly specified by your application during user creation (e.g. [email protected]). Exactly one of user_id and username must be specified.</param> /// <param name="device">ID of the device to send passcodes to. This device must have the "sms" capability. You may also specify "auto" to use the first of the user's devices with the "sms" capability.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> /// <param name="cancelToken">Cancellation Token in case you want to cancel mid-request.</param> public async Task <DuoResponse <AuthResult> > AuthSmsByUsernameAsync(string username, string device = "auto", string ipaddr = null, CancellationToken cancelToken = default) { var request = builder.AuthRequest(null, username, "sms", ipaddr, null, device, null); var response = await client.SendAsync(request, cancelToken).ConfigureAwait(false); return(await DuoResponse.ParseAsync <AuthResultModel, AuthResult>(response).ConfigureAwait(false)); }
/// <summary> /// https://duo.com/docs/authapi#/preauth /// </summary> /// <param name="user_id">Permanent, unique identifier for the user as generated by Duo upon user creation (e.g. DUYHV6TJBC3O4RITS1WC). Exactly one of user_id and username must be specified.</param> /// <param name="ipaddr">The IP address of the user to be authenticated, in dotted quad format. This will cause an "allow" response to be sent if appropriate for requests from a trusted network.</param> /// <param name="trusted_device_token">If the trusted_device_token is present and the Remembered Devices option is enabled in the Duo Admin Panel, return an "allow" response for the period of time a device may be remembered as set by the Duo administrator.</param> /// <param name="cancelToken">Cancellation Token in case you want to cancel mid-request.</param> public async Task <DuoResponse <PreAuthResult> > PreAuthByUserIdAsync(string user_id, string ipaddr = null, string trusted_device_token = null, CancellationToken cancelToken = default) { var request = builder.PreAuthRequest(user_id, null, ipaddr, trusted_device_token); var response = await client.SendAsync(request, cancelToken).ConfigureAwait(false); return(await DuoResponse.ParseAsync <PreAuthResultModel, PreAuthResult>(response).ConfigureAwait(false)); }
/// <summary> /// https://duo.com/docs/authapi#/logo /// </summary> public async Task <DuoResponse <LogoResult> > LogoAsync() { var request = builder.LogoRequest(); var response = await client.SendAsync(request).ConfigureAwait(false); if (!response.IsSuccessStatusCode) { return(await DuoResponse.ErrorAsync <LogoResult>(response)); } var content = await response.Content.ReadAsByteArrayAsync(); return(new DuoResponse <LogoResult> { IsSuccessful = true, OriginalResponse = response, Result = new LogoResult(content) }); }
/// <summary> /// https://duo.com/docs/authapi#/enroll_status /// </summary> /// <param name="user_id">ID of the user.</param> /// <param name="activation_code">Activation code, as returned from /enroll.</param> public async Task <DuoResponse <EnrollStatusResult> > EnrollStatusAsync(string user_id, string activation_code) { var request = builder.EnrollCheckRequest(user_id, activation_code); var response = await client.SendAsync(request).ConfigureAwait(false); var content = await response.Content.ReadAsStringAsync(); if (!response.IsSuccessStatusCode) { return(DuoResponse.Error <EnrollStatusResult>(response, content)); } var model = JsonConvert.DeserializeObject <BaseModel <string> >(content); return(new DuoResponse <EnrollStatusResult> { IsSuccessful = true, OriginalResponse = response, OriginalJson = content, Result = new EnrollStatusResult(model.Response) }); }