Skip to content

Instantly share code, notes, and snippets.

View krlsdu's full-sized avatar

Carlos krlsdu

View GitHub Profile
@krlsdu
krlsdu / 401_response_usar_em_detrimento_de_outros_response_codes_quando_falha_de_autenticacao
Last active July 26, 2021 02:29
401 response porque dar preferência ao notificar o usuário de uma falha de autenticação.
Na falha de autenticação há 3 razões principais para usar o 401,
1 - De acordo com a RFC esta requisição foi sim processada mas não foi provido credenciais VÁLIDAS por isso a não autorização.
2- Com o 401 a RFC OBRIGA que a resposta contenha o cabeçalho (WWW-Authenticate) com este cabeçalho você dá a chance do cliente(Browser, CLI, java.. N) perceber de forma clara que o erro pode ser corrigido ao refazer a chamada com as credenciais VALIDAS e qual o processo de authenticação utilizado neste caso (Bearer).
3- Considerando que o cliente (browser, CLI, javascript) implementa a RFC, a resposta entregue pela api basta agregar informação como mensagem de erro para exibição no front assim a de-serialização fica por conta da própria ferramenta e não precisa fazer tratamento (se 200 com msg XYZ então tratar como erro e exibir msg blablabla) é simplesmente(exibir msg blablabla).
Obs:
- 4xx indica erro por parte do cliente que requisitou seja humano usando o browser ou máquina usando http client.
- 200 não deixa cla
@krlsdu
krlsdu / BACKEND.md
Created August 27, 2020 03:46 — forked from akitaonrails/BACKEND.md
Codeminer 42 - BACKEND Test

TRZ (The Resident Zombie) - Backend

Problem Description

The world, as we know it, has fallen into an apocalyptic scenario. The "Influenzer T-Virus" (a.k.a. Twiter Virus) is transforming human beings into stupid beasts (a.k.a. Zombies), hungry to cancel humans and eat their limbs.

You, the last survivor who knows how to code, will help the resistance by deploying a system to connect the remaining humans. This system will be essential to detect new infections and share resources between the members.

Requirements

@krlsdu
krlsdu / gist:5a5df090cd1f55ee79045c702ea72566
Created November 1, 2019 16:48
comando para extrair seria,commonameEmissor,CommonameResponsavel de um certificado digital
openssl x509 -in certificadoXPTO -noout -serial -issuer -subject -nameopt multiline \
| grep 'serial\|commonName' \
| tr -s '[:space:]'
@krlsdu
krlsdu / gist:0749564b1a4da373551a84501473560e
Last active October 8, 2019 21:28
Create and Include custom launcher to favorite dock on ubuntu 18.04
gnome-desktop-item-edit ~/Desktop/ --create-new
dconf-editor
sudo apt-get install dconf-editor if not installed
org/gnome/shell/favorite-apps.
@krlsdu
krlsdu / configurar timezone dentro do container
Created September 4, 2019 16:33
configurar timezone dentro do container
&& ln -fs /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime \
&& dpkg-reconfigure --frontend noninteractive tzdata \
@krlsdu
krlsdu / Dockerfile
Created May 24, 2019 04:31
flyway-docker
FROM openjdk:8-jre
# Add the flyway user and step in the directory
RUN adduser --system --home /flyway --disabled-password --group flyway
WORKDIR /flyway
# Change to the flyway user
USER flyway
ENV FLYWAY_VERSION 6.0.0-beta
@krlsdu
krlsdu / openssl p12
Created October 24, 2018 22:00
Verificar certificado p12 via terminal linux sem precisar separar cert e key
openssl pkcs12 -in Certificado\ SE/EdmilsonSantos.p12 -passin pass:Adminwj001 | openssl x509 -noout -subject -inform PEM -text
@krlsdu
krlsdu / gist:b6d3124133b7082cf38a37fe714d7466
Created September 6, 2018 23:23
spring-boot-restassured-doc
= Spring REST Docs REST Assured Sample
Andy Wilkinson;
:doctype: book
:icons: font
:source-highlighter: highlightjs
:snippets: ../../../target/generated-snippets
Sample application demonstrating how to use Spring REST Docs with REST Assured.
`SampleRestAssuredApplicationTests` makes a call to a very simple service. The service
@startuml
!define SPRITESURL https://raw.githubusercontent.com/rabelenda/cicon-plantuml-sprites/v1.0/sprites
!define AWSPUML https://raw.githubusercontent.com/milo-minderbinder/AWS-PlantUML/release/18-2-22/dist
!define DEVICONS https://raw.githubusercontent.com/tupadr3/plantuml-icon-font-sprites/v2.0.0
!include <cloudinsight/haproxy.puml>
!include <material/common>
!include <material/webpack>
graph LR
subgraph Supcd Ambiente Prod
Tibico>Tibico]
postgres-transacional((postgres-transacional))
postgres-consulta((postgres-consulta))
postgres-emplaca((postgres-emplaca))
end