protected virtual BrowserAuthenticationForm GetAuthenticator(string connection, string scope, IDictionary <string, string> authParams = null, string device = null) { // Generate state to include in startUri var chars = new char[16]; var rand = new Random(); for (var i = 0; i < chars.Length; i++) { chars[i] = (char)rand.Next((int)'a', (int)'z' + 1); } var redirectUri = this.CallbackUrl; var authorizeUri = string.Format(AuthorizeUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), Uri.EscapeDataString(connection), Uri.EscapeDataString(scope)); // Add device if requested if (!string.IsNullOrEmpty(device)) { authorizeUri += String.Format(ParamQueryString, "device", Uri.EscapeDataString(device)); } // Add custom auth params to the request. if (authParams != null) { foreach (var authParam in authParams.Where(a => !ReservedAuthParams.Contains(a.Key))) { authorizeUri += String.Format(ParamQueryString, authParam.Key, Uri.EscapeDataString(authParam.Value)); } } this.State = new string(chars); var startUri = new Uri(authorizeUri + "&state=" + this.State); var endUri = new Uri(redirectUri); var auth = new BrowserAuthenticationForm(startUri, endUri); return(auth); }
protected virtual BrowserAuthenticationForm GetAuthenticator(string connection, string scope) { // Generate state to include in startUri var chars = new char[16]; var rand = new Random(); for (var i = 0; i < chars.Length; i++) { chars[i] = (char)rand.Next((int)'a', (int)'z' + 1); } var redirectUri = this.CallbackUrl; var authorizeUri = !string.IsNullOrWhiteSpace(connection) ? string.Format(AuthorizeUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), connection, scope) : string.Format(LoginWidgetUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), scope); this.State = new string(chars); var startUri = new Uri(authorizeUri + "&state=" + this.State); var endUri = new Uri(redirectUri); var auth = new BrowserAuthenticationForm(startUri, endUri); return(auth); }
protected virtual BrowserAuthenticationForm GetAuthenticator(string connection, string scope) { // Generate state to include in startUri var chars = new char[16]; var rand = new Random(); for (var i = 0; i < chars.Length; i++) { chars[i] = (char)rand.Next((int)'a', (int)'z' + 1); } var redirectUri = this.CallbackUrl; var authorizeUri = !string.IsNullOrWhiteSpace(connection) ? string.Format(AuthorizeUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), connection, scope) : string.Format(LoginWidgetUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), scope); this.State = new string(chars); var startUri = new Uri(authorizeUri + "&state=" + this.State); var endUri = new Uri(redirectUri); var auth = new BrowserAuthenticationForm(startUri, endUri); return auth; }
protected virtual BrowserAuthenticationForm GetAuthenticator(string connection, string scope, string device) { // Generate state to include in startUri var chars = new char[16]; var rand = new Random(); for (var i = 0; i < chars.Length; i++) { chars[i] = (char)rand.Next((int)'a', (int)'z' + 1); } var redirectUri = this.CallbackUrl; var authorizeUri = !string.IsNullOrWhiteSpace(connection) ? string.Format(AuthorizeUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), connection, scope) : string.Format(LoginWidgetUrl, this.domain, this.clientId, Uri.EscapeDataString(redirectUri), scope); if (!string.IsNullOrWhiteSpace(device)) { authorizeUri += $"&device={device}"; } this.State = new string(chars); var startUri = new Uri($"{authorizeUri}&state={this.State}"); var endUri = new Uri(redirectUri); var logoutEndRedirect = string.Format(DefaultLogoutCallback, this.domain); var logoutStartUri = new Uri(string.Format(LogoutUrl, this.domain, logoutEndRedirect)); var logoutEndUri = new Uri(logoutEndRedirect); var auth = new BrowserAuthenticationForm(startUri, endUri, logoutStartUri, logoutEndUri); return auth; }