@*******************************************************************************************************// 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());}<!DOCTYPE html><html><head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Login</title> <link href="@Resources.Root/Shared/Content/bootstrap.css" rel="stylesheet"> @Raw(Resources.HeaderIcons) <style> body { padding-top: 30px; } table { width: 100%; table-layout: fixed; border-radius: 0px; margin: 0px auto; float: none; } td { vertical-align: top; } label.inline { display: inline; } label.disabled { color: #ccc; } .panel-red { color: #a94442; background-color: #f2dede; border-color: #ebccd1; } .pre-cache { position: absolute; left: -999em; visibility: hidden } .glyphicon-spin { -webkit-animation: spin 1.25s infinite linear; -moz-animation: spin 1.25s infinite linear; -o-animation: spin 1.25s infinite linear; animation: spin 1.25s infinite linear; } @@-moz-keyframes spin { 0% { -moz-transform: rotate(0deg); } 100% { -moz-transform: rotate(359deg); } } @@-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); } 100% { -webkit-transform: rotate(359deg); } } @@-o-keyframes spin { 0% { -o-transform: rotate(0deg); } 100% { -o-transform: rotate(359deg); } } @@keyframes spin { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(359deg); transform: rotate(359deg); } } </style> <script> @Raw(new Minifier().MinifyJavaScript(constants)); </script></head><body role="document"> <span class="glyphicon glyphicon-refresh pre-cache"></span> <div class="container" role="main" id="bodyContainer"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12"> @Raw(loginHeader) <div class="panel panel-default"> <div class="panel-heading text-center"> <h4><span id="response">Enter credentials: </span> <span id="workingIcon" class="glyphicon glyphicon-refresh glyphicon-spin" style="display: none"></span></h4> </div> <div class="panel-body" id="credentialsForm"> @if (string.IsNullOrEmpty(oIDCError)) { <form role="form"> <div class="form-group"> <label for="username">User name:</label> <input type="text" class="form-control" id="username" /> </div> <div class="form-group"> <label for="password">Password:</label> <input type="password" class="form-control" id="password" /> </div> <table> <tr> <td> <div class="form-group"> <input type="checkbox" id="iwa" /> <label class="inline" for="iwa">Use Integrated Windows Authentication</label> </div> </td> <td style="text-align: center"> <div class="form-group"> <input type="checkbox" id="remember" /> <label class="inline" for="remember">Keep me signed in</label> </div> </td> <td style="text-align: right"> <div class="form-group" id="ntlmRegion" title="Uncheck this box if you are logging in with cached domain credentials and do not have domain access - e.g., roaming with a laptop"> <input type="checkbox" id="ntlm" checked disabled /> <label class="inline disabled" for="ntlm" id="ntlmLabel">Use NTLM authentication</label> <div id="ntlmMessage" style="color: red; display: none; max-width: 200px; float: right; overflow: hidden; margin-bottom: 10px"> <small> WARNING: Unsecured connection,<br />any credentials passed to host <span style="white-space: nowrap">"@request.RequestUri.Host"</span> will be sent <span style="white-space: nowrap">in clear-text</span> </small> </div> </div> </td> </tr> </table> <button type="button" class="btn btn-primary pull-right" id="login">Login</button> </form> } </div> <div class="panel-body" id="reloginForm" style="display: none"> <button type="button" class="btn btn-primary pull-right" id="returnToLogin">Return to Login</button> </div> <div class="panel-footer panel-red text-center" id="responsePanel" style="display: none"> <h5 id="message"></h5> </div> </div> </div> </div> </div> <script src="@Resources.Root/Shared/Scripts/jquery.js"></script> <script src="@Resources.Root/Shared/Scripts/bootstrap.js"></script> <script src="@Resources.Root/Shared/Scripts/gsf.web.client.js?ver=1"></script> <script src="@Resources.Root/Security/Scripts/core.js"></script> <script src="@Resources.Root/Security/Scripts/sha256.js"></script> <script src="@Resources.Root/Security/Scripts/enc-base64.js"></script> <script src="@Resources.Root/Security/Scripts/ntlm.js?ver=1"></script> <script src="@Resources.Root/Security/Scripts/Login.js?ver=2"></script></body></html>
@*******************************************************************************************************
// 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()
);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Login</title>
<link href="@Resources.Root/Shared/Content/bootstrap.css" rel="stylesheet">
@Raw(Resources.HeaderIcons)
<style>
body {
padding-top: 30px;
}
table {
width: 100%;
table-layout: fixed;
border-radius: 0px;
margin: 0px auto;
float: none;
}
td {
vertical-align: top;
}
label.inline {
display: inline;
}
label.disabled {
color: #ccc;
}
.panel-red {
color: #a94442;
background-color: #f2dede;
border-color: #ebccd1;
}
.pre-cache {
position: absolute;
left: -999em;
visibility: hidden
}
.glyphicon-spin {
-webkit-animation: spin 1.25s infinite linear;
-moz-animation: spin 1.25s infinite linear;
-o-animation: spin 1.25s infinite linear;
animation: spin 1.25s infinite linear;
}
@@-moz-keyframes spin {
0% {
-moz-transform: rotate(0deg);
}
100% {
-moz-transform: rotate(359deg);
}
}
@@-webkit-keyframes spin {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
}
}
@@-o-keyframes spin {
0% {
-o-transform: rotate(0deg);
}
100% {
-o-transform: rotate(359deg);
}
}
@@keyframes spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(359deg);
transform: rotate(359deg);
}
}
</style>
<script>
@Raw(new Minifier().MinifyJavaScript(constants));
</script>
</head>
<body role="document">
<span class="glyphicon glyphicon-refresh pre-cache"></span>
<div class="container" role="main" id="bodyContainer">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
@Raw(loginHeader)
<div class="panel panel-default">
<div class="panel-heading text-center">
<h4><span id="response">Enter credentials:
</span> <span id="workingIcon" class="glyphicon glyphicon-refresh glyphicon-spin" style="display: none"></span></h4>
</div>
<div class="panel-body" id="credentialsForm">
@if (string.IsNullOrEmpty(oIDCError))
{
<form role="form">
<div class="form-group">
<label for="username">User name:</label>
<input type="text" class="form-control" id="username" />
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" />
</div>
<table>
<tr>
<td>
<div class="form-group">
<input type="checkbox" id="iwa" />
<label class="inline" for="iwa">Use Integrated Windows Authentication</label>
</div>
</td>
<td style="text-align: center">
<div class="form-group">
<input type="checkbox" id="remember" />
<label class="inline" for="remember">Keep me signed in</label>
</div>
</td>
<td style="text-align: right">
<div class="form-group" id="ntlmRegion" title="Uncheck this box if you are logging in with cached domain credentials and do not have domain access - e.g., roaming with a laptop">
<input type="checkbox" id="ntlm" checked disabled />
<label class="inline disabled" for="ntlm" id="ntlmLabel">Use NTLM authentication</label>
<div id="ntlmMessage" style="color: red; display: none; max-width: 200px; float: right; overflow: hidden; margin-bottom: 10px">
<small>
WARNING: Unsecured connection,<br />any credentials passed to host
<span style="white-space: nowrap">"@request.RequestUri.Host"</span> will be sent
<span style="white-space: nowrap">in clear-text</span>
</small>
</div>
</div>
</td>
</tr>
</table>
<button type="button" class="btn btn-primary pull-right" id="login">Login</button>
</form>
}
</div>
<div class="panel-body" id="reloginForm" style="display: none">
<button type="button" class="btn btn-primary pull-right" id="returnToLogin">Return to Login</button>
</div>
<div class="panel-footer panel-red text-center" id="responsePanel" style="display: none">
<h5 id="message"></h5>
</div>
</div>
</div>
</div>
</div>
<script src="@Resources.Root/Shared/Scripts/jquery.js"></script>
<script src="@Resources.Root/Shared/Scripts/bootstrap.js"></script>
<script src="@Resources.Root/Shared/Scripts/gsf.web.client.js?ver=1"></script>
<script src="@Resources.Root/Security/Scripts/core.js"></script>
<script src="@Resources.Root/Security/Scripts/sha256.js"></script>
<script src="@Resources.Root/Security/Scripts/enc-base64.js"></script>
<script src="@Resources.Root/Security/Scripts/ntlm.js?ver=1"></script>
<script src="@Resources.Root/Security/Scripts/Login.js?ver=2"></script>
</body>
</html>