Coder Social home page Coder Social logo

food-api's Introduction

API de delivery de comida

Spring 2.3.4

Spring OAuth server

Java 15

RestFull HATEOAS

OpenApi Doc

HATEOAS Root path

development pre requisites:

  • maven
  • java 15
  • make
  • docker
  • aws cli
  • terraform

See Makefile

v1 Api auth

perfil Admin:
username: [email protected]
password: 123

perfil Cliente:
username: [email protected]
password: 123

perfil Cadastrador:
username: [email protected]
password: 123

Password Flow

clientId: food-web
clientSecret: web123
POST:
https://food-api-rfaguiar.herokuapp.com/oauth/token
Headers:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic Zm9vZC13ZWI6d2ViMTIz
Body:
username=[email protected]&password=123&grant_type=password

Implicit Flow

https://food-api-rfaguiar.herokuapp.com/oauth/authorize?response_type=token&client_id=webadmin&state=abc&redirect_uri=http://aplicacao-cliente

Client Credentials Flow

clientId: faturamento
clientSecret: faturamento123
POST:
https://food-api-rfaguiar.herokuapp.com/oauth/token
Headers:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic ZmF0dXJhbWVudG86ZmF0dXJhbWVudG8xMjM=
Body:
grant_type=client_credentials

Authorization Code Flow

clientId: food-analytics
clientSecret: food123

Login in your browser:

https://food-api-rfaguiar.herokuapp.com/oauth/authorize?response_type=code&client_id=food-analytics&state=abc&redirect_uri=http://localhost:8082

Request to generate token:

POST:
https://food-api-rfaguiar.herokuapp.com/oauth/token
Headers:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic Zm9vZC1hbmFseXRpY3M6Zm9vZDEyMw==
Body:
grant_type=authorization_code&redirect_uri=http://localhost:8082&code={substituir por codigo}

Authorization Code Flow com PKCE

clientId: food-analytics
clientSecret: food123

Login in your browser:

Code Verifier: teste123
Code Challenge: teste123
Obs mudar o method para s256 (SHA-256)
https://food-api-rfaguiar.herokuapp.com/oauth/authorize?response_type=code&client_id=food-analytics&state=abc&redirect_uri=http://localhost:8082&code_challeng_method=plain&code_challeng=teste123

sha-256 https://tonyxu-io.github.io/pkce-generator/

Another request in your browser:

Code Verifier: teste123
Code Challenge com base64 e sha256 base64url(sha256(teste123)): KJFg2w2fOfmuF1TE7JwW-QtQ4y4JxftUga5kKz09GjY
https://food-api-rfaguiar.herokuapp.com/oauth/authorize?response_type=code&client_id=food-analytics&state=abc&redirect_uri=http://localhost:8082&code_challeng_method=s256&code_challeng=KJFg2w2fOfmuF1TE7JwW-QtQ4y4JxftUga5kKz09GjY

Request to generate token:

POST: https://food-api-rfaguiar.herokuapp.com/oauth/token
Headers:
Content-Type: application/x-www-form-urlencoded
Authorization: Basic Zm9vZC1hbmFseXRpY3M6Zm9vZDEyMw==
Body:
grant_type=authorization_code&redirect_uri=http://localhost:8082&code=kUSmN8er&code_verifier=teste123

Getting Started

MySQL 8 docker

docker run --rm --name mysql8 --network minha-rede -v $(pwd)/mysql-datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -p 3306:3306 -d mysql:8

JDBC envs:

DB_URL DB_USER DB_PASS

AWS S3 envs:

S3_CHAVE_ACESSO S3_CHAVE_SECRETA S3_BUCKET_NAME S3_BUCKET_REGIAO S3_BUCKET_DIRETORIO

SMTP envs:

EMAIL_IMPL=SMTP MAIL_HOST MAIL_PORT MAIL_USER MAIL_PASSWORD MAIL_REMETENTE

Security envs:

JKS_BASE64 KEYSTORE_PASSWORD KEYSTORE_ALIAS

terraform:

before configure aws cli:

aws configure
  • Terraform change values terraform.tfvars set and terraform env vars

TF_VAR_db_username TF_VAR_db_password TF_VAR_db_username TF_VAR_db_password TF_VAR_jks_alias TF_VAR_jks_base64 TF_VAR_jks_password TF_VAR_mail_host TF_VAR_mail_password TF_VAR_mail_port TF_VAR_mail_remetente TF_VAR_mail_user TF_VAR_domain_name

cd terraform && terraform init && terraform apply
terraform output db_hostname

Reference Documentation

For further reference, please consider the following sections:

Tests Documentation

Guides

The following guides illustrate how to use some features concretely:

example generate jks and copy to memory ctrl + v

keytool -genkeypair -alias food -keyalg RSA -keypass 123@foodprd \
 -keystore food-prd.jks -storepass 123@foodprd -validity 3650
cat food-prd.jks | base64 | pbcopy

export local .env file to local envs

export $(xargs < .env)

aws ecs describe-tasks --cluster food-cluster --tasks a70cb56183564ce690c39b1a178bc417

food-api's People

Contributors

rfaguiar avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.