Code Monkey home page Code Monkey logo

exposed-ktor-jwt's Introduction

exposed-ktor-jwt

  • postgresql database running in docker for the local dev environment with configurable sql schema.
  • kotlin backend using: Jetbrains’ Exposed and Ktor. Kluent and Junit5 for tests.
  • backend secured with jwt tokens. It both creates and validates the tokens on selected routes.
  • frontend: angular 7 + angular material

Build

backend

$ cd backend && gradle build

frontend

$ cd frontend && yarn && yarn build

Execute

when using an IDE for kotlin (e.g. jetbrains’ Intellij)

  • boot the database with make db in the root dir
  • execute the main function (in main.kt)
  • cd frontend && yarn start
  • check localhost:4200

running the whole project in docker

  • build the backend: cd backend && gradle build
  • build the frontend: cd frontend && yarn && yarn build
  • go to the root dir and issue: make
  • note: you must have docker and docker-compose installed
  • check localhost:4200

Test the endpoints

testing the /secret endpoint with postman

  • see this so question
  • basically you have to issue a GET request containing a header row like this:
Key: 'Authorization'
Value: Bearer 'yourjwttokenASDFASDFdsfasdfDSAFasdfADfADfASdafAsdFASDF'

testing the /secret endpoint with curl

step 01: obtain and stash the token throught the /login endpoint

$ TOKEN=$(curl -s -X POST -d '{"name" : "alice", "password": "secret"}' -H "Content-Type: application/json"  localhost:8080/login | jq -r '.token')

step 02 issue a GET /secret with a header containing the token

$ curl -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" https://localhost:8080/secret

LICENSE

GNU General Public License v3
Copyright (c) 2019-2021 Filipe Silva (ninrod)

exposed-ktor-jwt's People

Contributors

ninrod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

revdfdev monkeyer

exposed-ktor-jwt's Issues

ERROR: Couldn't connect to Docker daemon

  • which docker image do we need?
$ make db
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
make: *** [makefile:13: db] Error 1

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.