Skip to content

Commit

Permalink
Merge pull request #9 from SRGSSR/develop
Browse files Browse the repository at this point in the history
[MASTER] Bootstrap update + Text column
  • Loading branch information
pyby authored May 16, 2018
2 parents 812e27a + 16ba625 commit 42f1cd6
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 28 deletions.
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>5.0.10</version>
</dependency>
</dependencies>

<build>
Expand Down
14 changes: 7 additions & 7 deletions portal-app/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>

<div class="container-fluid">
<div class="col-md-offset-1">
<h1>
Pfff
</h1>
<div class="container">
<div class="col-md-12">
<h1 class="text-center">Pfff - Admin</h1>
</div>

<a routerLink="/updates">List Updates</a>
<a style="margin-left:10px" routerLink="/add_update">Add Update</a>
<div class="btn-group-justified">
<a routerLink="/updates" class="btn btn-primary">List Updates</a>
<a routerLink="/add_update" class="btn btn-success">Add Update</a>
</div>
<br/>
<router-outlet></router-outlet>
</div>
7 changes: 3 additions & 4 deletions portal-app/src/app/update/add-update.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="col-md-6">
<div class="col-md-12">
<h2 class="text-center">Add Update</h2>
<form>
<div class="form-group">
Expand All @@ -16,9 +16,8 @@ <h2 class="text-center">Add Update</h2>
<input [(ngModel)]="update.text" name="text" class="form-control" id="text">
</div>

<div class="form-group">
<label for="mandatory">Mandatory:</label>
<input type="checkbox" [(ngModel)]="update.mandatory" name="mandatory" class="form-control" id="mandatory">
<div class="checkbox">
<label><input type="checkbox" [(ngModel)]="update.mandatory" name="mandatory" id="mandatory"> Mandatory</label>
</div>

<button class="btn btn-success" (click)="createUpdate()">Create</button>
Expand Down
4 changes: 2 additions & 2 deletions portal-app/src/app/update/update.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="col-md-6">
<h2> Update Details</h2>
<div class="col-md-12">
<h2 class="text-center">Update Details</h2>

<table class="table table-striped">
<thead>
Expand Down
11 changes: 9 additions & 2 deletions portal-app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>PortalApp</title>
<title>Pfff - Admin</title>
<base href="/">

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> -->
<link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>
<script type="text/javascript" src="/webjars/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/webjars/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/webjars/font-awesome/css/font-awesome.min.css"/>
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/com/example/pfff/config/AuthenticationConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.pfff.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand All @@ -21,11 +22,23 @@
@Configuration
@EnableWebSecurity
public class AuthenticationConfig extends WebSecurityConfigurerAdapter {

private String user;
private String password;

public AuthenticationConfig(
@Value("${PFFF_USER:}") String user,
@Value("${PFFF_PASSWORD:}") String password) {

this.user = user;;
this.password = password;
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/api/v1/update/check", "/api/v1/whatisnew/text", "/api/v1/whatisnew/html", "/api/v1/version").permitAll()
.antMatchers("/api/v1/update/check", "/api/v1/whatisnew/text", "/api/v1/whatisnew/html", "/api/v1/version", "/webjars/**/*").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
Expand All @@ -41,12 +54,16 @@ protected void configure(HttpSecurity http) throws Exception {
@Bean
@Override
public UserDetailsService userDetailsService() {
UserDetails user =
User.withUsername("user")
.password("password")
if (user == null || user.length() == 0 || password == null || password.length() == 0) {
return null;
}

UserDetails userDetails =
User.withUsername(user)
.password(password)
.roles("USER")
.build();

return new InMemoryUserDetailsManager(Collections.singleton(user));
return new InMemoryUserDetailsManager(Collections.singleton(userDetails));
}
}
34 changes: 26 additions & 8 deletions src/main/resources/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,37 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Spring Security Example </title>
<title>Pfff - Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/webjars/bootstrap/css/bootstrap.min.css"/>
<script type="text/javascript" src="/webjars/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/webjars/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="/webjars/font-awesome/css/font-awesome.min.css"/>
</head>

<body>
<div th:if="${param.error}">
<div class="container">
<h2 class="text-center">Pfff - Login</h2>
</div>
<div class="alert alert-danger alert-dismissible" th:if="${param.error}">
<a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
Invalid username and password.
</div>
<div th:if="${param.logout}">
<div class="alert alert-success" th:if="${param.logout}">
You have been logged out.
</div>
<form th:action="@{/login}" method="post">
<div><label> User Name : <input type="text" name="username"/> </label></div>
<div><label> Password: <input type="password" name="password"/> </label></div>
<div><input type="submit" value="Sign In"/></div>
</form>
<div class="container">
<form th:action="@{/login}" method="post">
<div class="form-group">
<label for="text">User Name :</label>
<input type="text" name="username" class="form-control" id="text"/>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" name="password" class="form-control" id="pwd"/>
</div>
<button type="submit" class="btn btn-primary">Sign In</button>
</form>
</div>
</body>
</html>

0 comments on commit 42f1cd6

Please sign in to comment.