-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from linkaraj/master
OAuth2 support to access the restricted resources
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Sign in - HAL Browser</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link href="vendor/css/bootstrap.css" rel="stylesheet"> | ||
<link href="vendor/css/bootstrap-responsive.css" rel="stylesheet"> | ||
<style type="text/css"> | ||
body { | ||
padding-top: 40px; | ||
padding-bottom: 40px; | ||
background-color: #f5f5f5; | ||
} | ||
.form-signin { | ||
max-width: 300px; | ||
padding: 19px 29px 29px; | ||
margin: 0 auto 20px; | ||
background-color: #fff; | ||
border: 1px solid #e5e5e5; | ||
-webkit-border-radius: 5px; | ||
-moz-border-radius: 5px; | ||
border-radius: 5px; | ||
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, .05); | ||
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, .05); | ||
box-shadow: 0 1px 2px rgba(0, 0, 0, .05); | ||
} | ||
.form-signin .form-signin-heading { | ||
margin-bottom: 10px; | ||
} | ||
.form-signin input[type="text"], .form-signin input[type="password"] { | ||
font-size: 16px; | ||
height: auto; | ||
margin-bottom: 15px; | ||
padding: 7px 9px; | ||
} | ||
</style> | ||
<script src="vendor/js/jquery-1.10.2.min.js"></script> | ||
<script src="vendor/js/bootstrap.js"></script> | ||
<script> | ||
$(document).ready(function() { | ||
$('#form-signin').submit(function(event){ | ||
event.preventDefault(); | ||
$.ajax({ | ||
url : '../oauth/token', | ||
type : 'POST', | ||
async : false, | ||
data : 'password='+$("#password").val()+'&username='+$("#username").val()+'&grant_type=password', | ||
headers : { | ||
Authorization : 'Basic ' + btoa($("#clientid").val() + ':' + $("#clientsecret").val()), | ||
"Content-Type" : 'application/x-www-form-urlencoded', | ||
"Accept" : 'application/json' | ||
}, | ||
dataType : 'json', | ||
success : function(data) { | ||
document.cookie = "MyHalBrowserToken=" + data.access_token; | ||
window.location.href = 'browser.html' | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<form class="form-signin" id="form-signin"> | ||
<h3 class="form-signin-heading">HAL Browser - OAuth2</h3> | ||
<input type="text" class="input-block-level" placeholder="Client ID" id="clientid"> | ||
<input type="text" class="input-block-level" placeholder="Client Secret" id="clientsecret"> | ||
<input type="text" class="input-block-level" placeholder="Username" id="username"> | ||
<input type="password" class="input-block-level" placeholder="Password" id="password"> | ||
<button type="submit" class="btn btn-large btn-primary" id="login">Sign in</button> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |