-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomAuthnClient.cs
More file actions
58 lines (51 loc) · 2.08 KB
/
CustomAuthnClient.cs
File metadata and controls
58 lines (51 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Threading;
using System.Threading.Tasks;
using Okta.Auth.Sdk;
using Okta.Auth.Sdk.Models;
using Okta.Sdk.Abstractions;
using Okta.Sdk.Abstractions.Configuration;
namespace OktaDemo
{
public class CustomAuthnClient : AuthenticationClient
{
public CustomAuthnClient(IDataStore dataStore, OktaClientConfiguration clientConfiguration, RequestContext requestContext)
: base(dataStore, clientConfiguration, requestContext)
{
}
public async Task<IAuthenticationResponse> AuthenticateAsync(AuthenticateOptions authenticateOptions, CancellationToken cancellationToken = default(CancellationToken))
{
var authenticationRequest = new AuthenticationRequest()
{
Username = authenticateOptions.Username,
Password = authenticateOptions.Password,
Audience = authenticateOptions.Audience,
RelayState = authenticateOptions.RelayState,
StateToken = authenticateOptions.StateToken,
Options = new AuthenticationRequestOptions()
{
MultiOptionalFactorEnroll = authenticateOptions.MultiOptionalFactorEnroll,
WarnBeforePasswordExpired = authenticateOptions.WarnBeforePasswordExpired,
},
Context = new AuthenticationRequestContext()
{
DeviceToken = authenticateOptions.DeviceToken,
},
};
var request = new HttpRequest
{
Uri = "/api/v1/authn",
Payload = authenticationRequest,
};
request.Headers["X-Forwarded-For"] = this.GetXForwadedIP();
return await this.PostAsync<AuthenticationResponse>(
request, cancellationToken).ConfigureAwait(false);
}
private string GetXForwadedIP()
{
string xForwadedIP;
xForwadedIP = "9.8.9.8";
return xForwadedIP;
}
}
}