@******************************************************************************************************* // Login.cshtml - Gbtc // // Copyright © 2017, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 08/22/2017 - J. Ritchie Carroll // Generated original version of source code. // //*****************************************************************************************************@ @using System.Net @using System.Net.Http @using System.Text @using GSF.Web @using GSF.Web.Model @using GSF.Web.Security @using GSF.Web.Shared @using Microsoft.Ajax.Utilities @inherits ExtendedTemplateBase @{ HttpRequestMessage request = ViewBag.Request; string redirectPage; string authTestPage = AuthenticationOptions.DefaultAuthTestPage; string loginPage = AuthenticationOptions.DefaultLoginPage; string logoutPage = AuthenticationOptions.DefaultLogoutPage; string clearCredentials = AuthenticationOptions.DefaultClearCredentialsParameter; string verificationHeader = AuthenticationOptions.DefaultRequestVerificationToken; string verificationValue = Html.RequestVerificationHeaderToken(); string useAjaxVerfication = AuthenticationOptions.DefaultAjaxRequestVerificationToken; string loginHeader = ""; bool unsecureConnection = request.RequestUri.Scheme != "https" && !request.RequestUri.IsLoopback; string oIDCError = ""; if (request.QueryParameters().TryGetValue("redir", out redirectPage)) { string base64Path = WebUtility.UrlDecode(redirectPage); byte[] pathBytes = Convert.FromBase64String(base64Path); redirectPage = Encoding.UTF8.GetString(pathBytes); } else { redirectPage = "/"; } if (request.QueryParameters().TryGetValue("oidcError", out oIDCError)) { oIDCError = WebUtility.UrlDecode(oIDCError); } else { oIDCError = ""; } string redirectPageLabel = redirectPage == "/" ? "main" : "target"; ReadonlyAuthenticationOptions options = ViewBag.AuthenticationOptions; if ((object)options != null) { if (!string.IsNullOrWhiteSpace(options.AuthTestPage)) { authTestPage = options.AuthTestPage; } if (!string.IsNullOrWhiteSpace(options.LoginPage)) { loginPage = options.LoginPage; } if (!string.IsNullOrWhiteSpace(options.LogoutPage)) { logoutPage = options.LogoutPage; } if (!string.IsNullOrWhiteSpace(options.ClearCredentialsParameter)) { clearCredentials = options.ClearCredentialsParameter; } if (!string.IsNullOrWhiteSpace(options.RequestVerificationToken)) { verificationHeader = options.RequestVerificationToken; } if (!string.IsNullOrWhiteSpace(options.AjaxRequestVerificationToken)) { useAjaxVerfication = options.AjaxRequestVerificationToken; } // Login header is used set custom logo and application title for page loginHeader = options.LoginHeader; } bool useAlternateSecurityProvider = false; string p; if (request.QueryParameters().TryGetValue("useAlternateSecurityProvider", out p)) { useAlternateSecurityProvider = true; } string constants = string.Format(@" const redirectPage = ""{0}""; const securePage = ""{1}""; const loginPage = ""{2}""; const logoutPage = ""{3}"" + ""?{4}=true""; const unsecureConnection = {5}; const verificationHeader = ""{6}""; const verificationValue = ""{7}""; const useAjaxVerfication = ""{8}""; const redirectPageLabel = ""{9}""; const useAlternateSecurityProvider = {10}; const oidcError = ""{11}""; ", /* 0 */ redirectPage.JavaScriptEncode(), /* 1 */ authTestPage.JavaScriptEncode(), /* 2 */ loginPage.JavaScriptEncode(), /* 3 */ logoutPage.JavaScriptEncode(), /* 4 */ clearCredentials.JavaScriptEncode(), /* 5 */ unsecureConnection.ToString().ToLowerInvariant(), /* 6 */ verificationHeader.JavaScriptEncode(), /* 7 */ verificationValue.JavaScriptEncode(), /* 8 */ useAjaxVerfication.JavaScriptEncode(), /* 9 */ redirectPageLabel.JavaScriptEncode(), /* 10 */ useAlternateSecurityProvider.ToString().ToLowerInvariant(), /* 11 */ oIDCError.JavaScriptEncode() ); }