Skip to content

Commit 48e6895

Browse files
committed
Updated Security
-- WEB API -- -Added authorize attribute to controllers -Deleted readme.me -- WEB CLIENT -- -Removed default login credential in login form -Updated footer
1 parent c28cb51 commit 48e6895

File tree

13 files changed

+60
-56
lines changed

13 files changed

+60
-56
lines changed

WebApi/Controllers/AccountsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace WebApi.Controllers
1717
{
18-
// [Authorize(Roles = "Admin")]
18+
[Authorize(Roles = "Admin")]
1919
[Route("api/[controller]")]
2020
public class AccountsController : ControllerBase
2121
{

WebApi/Controllers/ConfigController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace WebApi.Controllers
1717
{
18+
[Authorize(Roles = "Admin")]
1819
[Route("api/[controller]")]
1920
[ApiController]
2021
public class ConfigController : ControllerBase

WebApi/Controllers/EmployeeController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace WebApi.Controllers
1717
{
18+
[Authorize(Roles = "Admin")]
1819
[Route("api/[controller]")]
1920
[ApiController]
2021
public class EmployeeController : ControllerBase
@@ -43,6 +44,7 @@ public async Task<IActionResult> Find(Guid id)
4344
return new OkObjectResult( JsonConvert.SerializeObject(res, settings) );
4445
}
4546

47+
4648
// PUT api/employee
4749
[HttpPut]
4850
public async Task<IActionResult> Update([FromBody]EmployeeViewModel model)

WebApi/Controllers/LogController.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace WebApi.Controllers
1717
{
18+
[Authorize]
1819
[Route("api/[controller]")]
1920
[ApiController]
2021
public class LogController : ControllerBase
@@ -37,6 +38,7 @@ public async Task<IActionResult> Index()
3738

3839
// POST api/log
3940
[HttpPost]
41+
[AllowAnonymous]
4042
public async Task<IActionResult> Log([FromBody] LogInOutViewModel model)
4143
{
4244
var user = await _service.CheckCardNo(model);
@@ -51,6 +53,7 @@ public async Task<IActionResult> Log([FromBody] LogInOutViewModel model)
5153

5254
// PUT api/log
5355
[HttpPut]
56+
[Authorize(Roles = "Admin")]
5457
public async Task<IActionResult> Update([FromBody]LogEditViewModel model)
5558
{
5659
try

WebApi/Repositories/ContextRepository.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ public ContextRepository(DbContext context)
1919
_dbSet = context.Set<TEntity>();
2020
}
2121

22-
private static object GetPropValue(object src, string propName)
23-
{
24-
return src.GetType().GetProperty(propName).GetValue(src, null);
25-
}
26-
2722
public TEntity GetFirstOrDefault(Expression<Func<TEntity, bool>> filter = null, params Expression<Func<TEntity, object>>[] includes)
2823
{
2924
IQueryable<TEntity> query = _dbSet;

WebApi/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
4545
// This method gets called by the runtime. Use this method to add services to the container.
4646
public void ConfigureServices(IServiceCollection services)
4747
{
48-
// string SecretKey = Configuration["AppSecret"];
49-
string SecretKey = "141FE29A91D7FA1A13F3C713BB789";
48+
string SecretKey = Configuration["AppSecret"];
49+
// string SecretKey = "141FE29A91D7FA1A13F3C713BB789";
5050
SymmetricSecurityKey _signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(SecretKey));
5151

5252
// Add framework services.

WebApi/appsettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"Audience": "http://localhost:5000/"
1414
},
1515
"DefaultAdminCredentials": {
16-
"UserName": "superadmin",
16+
"UserName": "admin",
1717
"Password": "123456"
1818
},
1919
"AttendanceConfig": {
2020
"TimeIn": "9:00",
2121
"TimeOut": "18:00",
22-
"GracePeriod": "15"
22+
"GraceTime": "15"
2323
}
2424
}

WebClient/README.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

WebClient/src/App.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
11
<template>
22
<div id="app">
33
<v-app dark>
4-
<app-header />
5-
<v-content>
6-
<!-- <transition name="fade-transition"> -->
7-
<router-view />
8-
<!-- </transition> -->
9-
<notifications />
10-
</v-content>
11-
<v-footer app>
12-
<span>&copy; 2018</span>
13-
</v-footer>
4+
<app-header />
5+
<v-content>
6+
<router-view />
7+
<notifications />
8+
</v-content>
9+
<app-footer />
10+
<!-- <v-footer app>
11+
<span>&copy; 2018</span>
12+
</v-footer> -->
1413
</v-app>
1514
</div>
1615
</template>
1716

1817
<script>
1918
import AppHeader from '@/views/app-header'
19+
import AppFooter from '@/views/app-footer'
2020
2121
export default {
2222
name: 'App',
2323
components: {
24-
AppHeader
24+
AppHeader,
25+
AppFooter
2526
}
2627
}
2728
</script>
@@ -30,7 +31,6 @@ export default {
3031
.vue-notification {
3132
padding: 10px;
3233
margin: 12px 5px 0 5px;
33-
3434
font-size: 14px;
3535
}
3636
</style>

WebClient/src/components/log-employee-form.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
<script>
2525
import { LOG_EMPLOYEE } from '@/store/actions-type'
2626
import { mapGetters } from 'vuex'
27-
// import { HubConnection } from '@aspnet/signalr'
2827
import * as signalR from "@aspnet/signalr";
2928
3029

0 commit comments

Comments
 (0)