This file contains hidden or 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
@RequestMapping("login") | |
public String login() { | |
return "login"; // will look for login.jsp inside WEB-INF/jsp/ | |
} |
This file contains hidden or 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
@Autowired | |
OAuth2AuthorizedClientService authclientService; | |
@RequestMapping("/oauth2LoginSuccess") | |
public String getOauth2LoginInfo(Model model,@AuthenticationPrincipal OAuth2AuthenticationToken authenticationToken) { | |
// fetching the client details and user details | |
System.out.println(authenticationToken.getAuthorizedClientRegistrationId()); // client name like facebook, google etc. | |
System.out.println(authenticationToken.getName()); // facebook/google userId | |
// 1.Fetching User Info |
This file contains hidden or 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
@RequestMapping("/formLoginSuccess") | |
public String getFormLoginInfo(Model model, @AuthenticationPrincipal Authentication authentication) { | |
// In form-based login flow you get UserDetails as principal while in Oauth based flow you get Oauth2User | |
UserDetails userDetails = (UserDetails) authentication.getPrincipal(); | |
model.addAttribute("name", userDetails.getUsername()); | |
return "home"; | |
} |
This file contains hidden or 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
<form action="/login" method="post"> | |
<h2 class="text-center">Sign in</h2> | |
<div class="text-center social-btn"> | |
<a href="/oauth2/authorization/facebook" class="btn btn-primary btn-block"><i class="fa fa-facebook"></i> Sign in with <b>Facebook</b></a> | |
<!-- <a href="/oauth2/authorization/google" class="btn btn-info btn-block"><i class="fa fa-google"></i> Sign in with <b>Google</b></a> --> | |
</div> | |
<div class="or-seperator"><i>or</i></div> | |
<div class="form-group"> | |
<div class="input-group"> | |
<span class="input-group-addon"><i class="fa fa-user"></i></span> |
This file contains hidden or 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
spring: | |
security: | |
oauth2: | |
client: | |
registration: | |
facebook: | |
client-id: <facebook client Id> | |
client-secret: <facebook secret Id> | |
scope: | |
This file contains hidden or 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
<div class="container"> | |
<nav class="navbar navbar-expand-lg navbar-light bg-light"> | |
<a class="navbar-brand" href="#">Dashboard</a> | |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> | |
<span class="navbar-toggler-icon"></span> | |
</button> | |
<div class="collapse navbar-collapse" id="navbarSupportedContent"> | |
<ul class="navbar-nav mr-auto"> | |
<li class="nav-item active"> | |
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a> |
This file contains hidden or 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
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - | |
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | |
sudo apt-get update | |
sudo apt-get install vault |
This file contains hidden or 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
root@rajeev-Latitude-5480:/home/rajeev# vault operator init -address=http://127.0.0.1:8200 | |
Unseal Key 1: UGumETpBdy/CAQRUT2vpIk+AExIjptJRwEFch9Z0XDK1 | |
Unseal Key 2: waqRq56mn1YAdf6wvjZ6Dz1TwqkC4ZGegAqM/lp4e9TN | |
Unseal Key 3: NNlZugZmOdSjUQtDwGBIEKaBQ0DN/exskH7kSH6X3dXZ | |
Unseal Key 4: KQ9C8yqkN4ejPPubsiSQjz2hABXmwqbAza5/e6q3d3O6 | |
Unseal Key 5: XLgPYeRDVRneQXQ+qttQRrEC0vJdE75LaJappezUZ7GQ | |
Initial Root Token: s.lL1wRFK79QQQRflLyIS3WyYm | |
Vault initialized with 5 key shares and a key threshold of 3. Please securely |
This file contains hidden or 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
listener "tcp" { | |
address = "127.0.0.1:8200" | |
tls_disable = true | |
} | |
storage "file" { | |
path = "/opt/vault/data" | |
} | |
ui = true |
This file contains hidden or 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
root@rajeev-Latitude-5480:/home/rajeev# vault operator unseal waqRq56mn1YAdf6wvjZ6Dz1TwqkC4ZGegAqM/lp4e9TN | |
Key Value | |
- - - - - | |
Seal Type shamir | |
Initialized true | |
Sealed true | |
Total Shares 5 | |
Threshold 3 | |
Unseal Progress 2/3 | |
Unseal Nonce 181be784–7c72-a040–48a5–105eb398f026 |