Skip to content

Commit e8888ed

Browse files
Revisão e layout
1 parent 00ac859 commit e8888ed

File tree

4 files changed

+52
-37
lines changed

4 files changed

+52
-37
lines changed

Gemfile

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
11
source "https://rubygems.org"
2-
# Hello! This is where you manage which Jekyll version is used to run.
3-
# When you want to use a different version, change it below, save the
4-
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
5-
#
6-
# bundle exec jekyll serve
7-
#
8-
# This will help ensure the proper Jekyll version is running.
9-
# Happy Jekylling!
10-
#gem "jekyll", "~> 4.3.3"
11-
# This is the default theme for new Jekyll sites. You may change this to anything you like.
12-
#gem "minima", "~> 2.5"
13-
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
14-
# uncomment the line below. To upgrade, run `bundle update github-pages`.
2+
153
gem "github-pages", "~> 231", group: :jekyll_plugins
16-
# If you have any plugins, put them here!
4+
175
group :jekyll_plugins do
186
gem "jekyll-paginate"
197
gem "jekyll-feed", "~> 0.12"
208
end
219

22-
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
23-
# and associated library.
2410
platforms :mingw, :x64_mingw, :mswin, :jruby do
2511
gem "tzinfo", ">= 1", "< 3"
2612
gem "tzinfo-data"
2713
end
2814

2915
gem 'jekyll-seo-tag'
3016
gem "webrick"
31-
# Performance-booster for watching directories on Windows
3217
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
33-
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
34-
# do not have a Java counterpart.
3518
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]

_config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,26 @@ defaults:
3434
values:
3535
layout: "post"
3636

37+
markdown: kramdown
38+
highlighter: rouge
39+
40+
kramdown:
41+
input: GFM
42+
# https://github.com/jekyll/jekyll/pull/4090
43+
syntax_highlighter: rouge
44+
syntax_highlighter_opts:
45+
css_class: 'highlight'
46+
span:
47+
line_numbers: false
48+
block:
49+
line_numbers: true
50+
start_line: 1
51+
3752
# Plugins
3853
plugins:
3954
- jekyll-paginate
4055
- jekyll-seo-tag
56+
- kramdown-syntax-coderay
4157

4258
# Custom variables
4359
version: "1.0.0"

_posts/2018-08-23-criando-aplicacao-web-com-aspnet-core-mvc-parte-1.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Para que possamos iniciar o desenvolvido, é necessário instalar algumas ferram
3636

3737
Quanto o uso da IDE, poderá utilizar qualquer uma das citadas. Vale ressaltar que diferente do Visual Studio Code e do MonoDevelop, o Microsoft Visual Studio é exclusivo do Windows. Sendo assim, para Mac e Linux deverá fazer uso dos outros dois citados.
3838

39-
[![](/contents/2018/08/0_mono_develop-1024x576.jpg)](/contents/2018/08/0_mono_develop.jpg)
39+
[](/contents/2018/08/0_mono_develop-1024x576.jpg)
4040

4141
Caso esteja utilizando o Mac, o SQL Server deverá ser executado em um Container no Docker, já para sistemas Linux, também poderá ser executado em um Container ou instalado diretamente caso sua versão seja suportada.
4242

@@ -110,7 +110,7 @@ Repare que temos os diretórios, _Home_ e _Secure_. No _Home_ temos o _Index_ do
110110

111111
Em relação ao banco de dados, criaremos a tabela _Usuario_. Para essa primeira parte iremos somente autenticar no painel.
112112

113-
```
113+
```sql
114114
CREATE TABLE Usuario
115115
(
116116
IdUsuario INT IDENTITY(1, 1) NOT NULL,
@@ -125,13 +125,13 @@ GO
125125

126126
Vamos incluir também o usuário administrador
127127

128-
```
128+
```sql
129129
INSERT INTO Usuario (Nome, Login, Senha) VALUES ('Administrador', 'admin', '123456')
130130
```
131131

132132
Para a camada de Dados, criamos o ApplicationContext e o repositório de usuários. O ApplicationContext é a classe que implementa o DbContext que é responsável por abrir conexão de nossa aplicação com o banco de dados. Já o repositório nos permitirá utilizar o ApplicationContext para interagir com nossas tabelas realizando operações de consulta, inclusão, exclusão e atualização. Inicialmente teremos somente o repositório de usuário para que possamos implementar a autenticação.
133133

134-
```
134+
```csharp
135135
using System;
136136
using CriandoAplicacaoAspNetCore.Data.Mapping;
137137
using CriandoAplicacaoAspNetCore.Model.Entities;
@@ -155,7 +155,7 @@ namespace CriandoAplicacaoAspNetCore.Data
155155
}
156156
}
157157
}
158-
``````
158+
```csharp
159159
using System;
160160
using CriandoAplicacaoAspNetCore.Model.Entities;
161161
using CriandoAplicacaoAspNetCore.Model.Interfaces;
@@ -174,7 +174,7 @@ namespace CriandoAplicacaoAspNetCore.Data.Repositories
174174

175175
Repare que nosso repositório de usuário não possui nenhum metodo implementado. Ele herda do GenericRepository todas os métodos necessários.
176176

177-
```
177+
```csharp
178178
using System;
179179
using System.Collections.Generic;
180180
using System.Linq;
@@ -210,7 +210,8 @@ namespace CriandoAplicacaoAspNetCore.Data.Repositories
210210
return this._dbSet.Find(id);
211211
}
212212

213-
public virtual IQueryable Get(Expression<Func<TEntity, bool>> expression = null, Func<iqueryable, IOrderedQueryable> orderby = null, string includes = "", bool noTracking = false)
213+
public virtual IQueryable Get(Expression<Func<TEntity, bool>> expression = null,
214+
Func<iqueryable, IOrderedQueryable> orderby = null, string includes = "", bool noTracking = false)
214215
{
215216
IQueryable query = this._dbSet;
216217

@@ -277,7 +278,7 @@ namespace CriandoAplicacaoAspNetCore.Data.Repositories
277278

278279
Na camada de negócio, criamos o código que irá autenticar o usuário.
279280

280-
```
281+
```csharp
281282
using System;
282283
using System.Linq;
283284
using System.Linq.Expressions;
@@ -298,7 +299,8 @@ namespace CriandoAplicacaoAspNetCore.Business
298299

299300
public virtual UsuarioDto Autenticar(LoginDto loginDto)
300301
{
301-
Expression<Func<Usuario, bool>> expression = q => q.Login.ToLower().Equals(loginDto.Usuario) && q.Senha.Equals(loginDto.Senha);
302+
Expression<Func<Usuario, bool>> expression = q => q.Login.ToLower().Equals(loginDto.Usuario) &&
303+
q.Senha.Equals(loginDto.Senha);
302304
var usuarioDto = this._unitOfWork.UsuarioRepository
303305
.Get(expression)
304306
.Select(s => new UsuarioDto
@@ -320,7 +322,7 @@ Não me preocupei muito com a parte de segurança nesse momento. Então, nossa s
320322

321323
Tendo agora nossa camada de dados e de negócio pronta, poderemos criar o controller que será o reponsável por interagir com a nossa view. Criamos então o controller do login em nosso Web Application.
322324

323-
```
325+
```csharp
324326
using System;
325327
using System.Collections.Generic;
326328
using System.Security.Claims;
@@ -378,7 +380,9 @@ namespace CriandoAplicacaoAspNetCore.WebApp.Areas.Painel.Controllers
378380
ExpiresUtc = DateTime.UtcNow.AddMinutes(2)
379381
};
380382

381-
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, authProperties);
383+
await HttpContext
384+
.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,
385+
principal, authProperties);
382386

383387
return RedirectToAction("Index", "Home");
384388
}

_posts/2019-05-30-criando-aplicacao-web-com-aspnet-core-mvc-parte-2.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ Criaremos também a view referente a tela de consulta de usuários.
8181

8282
<div class="row mt-4 mb-4">
8383
<div class="col">
84-
<a class="btn btn-primary" asp-area="Painel" asp-controller="Usuario" asp-action="Novo"><i class="fas fa-plus-circle"></i> Novo</a>
84+
<a class="btn btn-primary" asp-area="Painel" asp-controller="Usuario" asp-action="Novo">
85+
<i class="fas fa-plus-circle"></i> Novo
86+
</a>
8587
</div>
8688
</div>
8789

@@ -101,8 +103,16 @@ Criaremos também a view referente a tela de consulta de usuários.
101103
{
102104
<tr>
103105
<th scope="row">
104-
<a class="btn btn-info btn-sm" asp-area="Painel" asp-controller="Usuario" asp-action="Editar" asp-route-id="@item.IdUsuario"><i class="fas fa-pen-alt"></i></a>
105-
<a class="btn btn-danger btn-sm" asp-area="Painel" asp-controller="Usuario" asp-action="Excluir" asp-route-id="@item.IdUsuario"><i class="fas fa-trash-alt"></i></a>
106+
<a class="btn btn-info btn-sm" asp-area="Painel"
107+
asp-controller="Usuario" asp-action="Editar"
108+
asp-route-id="@item.IdUsuario">
109+
<i class="fas fa-pen-alt"></i>
110+
</a>
111+
<a class="btn btn-danger btn-sm" asp-area="Painel"
112+
asp-controller="Usuario" asp-action="Excluir"
113+
asp-route-id="@item.IdUsuario">
114+
<i class="fas fa-trash-alt"></i>
115+
</a>
106116
</th>
107117
<td>@item.Nome</td>
108118
<td>@item.Login</td>
@@ -153,9 +163,9 @@ namespace CriandoAplicacaoAspNetCore.Utils
153163

154164
public static string CreateHash(string value, string salt)
155165
{
156-
var valueBytes = KeyDerivation.Pbkdf2(password: value, salt: Encoding.UTF8.GetBytes(salt),
157-
prf: KeyDerivationPrf.HMACSHA512, iterationCount: ITERATION_COUNT,
158-
numBytesRequested: 256 / 8);
166+
var valueBytes = KeyDerivation
167+
.Pbkdf2(password: value, salt: Encoding.UTF8.GetBytes(salt),
168+
prf: KeyDerivationPrf.HMACSHA512, iterationCount: ITERATION_COUNT, numBytesRequested: 256 / 8);
159169
return Convert.ToBase64String(valueBytes);
160170
}
161171

@@ -178,7 +188,9 @@ ALTER TABLE usuario ADD Salt VARCHAR(256)
178188
E atualizaremos a senha do usuário _**Admin**_ para a senha padrão _**123456**_, porém, será armazenado somente o Hash e o Salt. Não teremos mais a senha gravada.
179189

180190
```sql
181-
UPDATE Usuario SET Hash = 'NLAZBttBU8HbUrODUPQxViEDr1d7RMi4B/2F6yaKOrQ=', Salt = 'Nkt8krN4/TBHUJXu4zEm6A=='
191+
UPDATE Usuario SET
192+
Hash = 'NLAZBttBU8HbUrODUPQxViEDr1d7RMi4B/2F6yaKOrQ=',
193+
Salt = 'Nkt8krN4/TBHUJXu4zEm6A=='
182194
WHERE Login = 'admin'
183195
```
184196

0 commit comments

Comments
 (0)