All Projects β†’ jeongukjae β†’ flask-jwt-login

jeongukjae / flask-jwt-login

Licence: MIT license
Flask extension that helps authentication using JWT (for a personal purpose, not maintained now)

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to flask-jwt-login

Flask-GraphQL-Auth
(UNMAINTAINED. FEEL FREE TO FORK) 🐍A Pythonic way to provide JWT authentication for Flask-GraphQL
Stars: ✭ 64 (+433.33%)
Mutual labels:  flask-extensions, flask-extension
flask-funnel
Better asset management for Flask
Stars: ✭ 22 (+83.33%)
Mutual labels:  flask-extensions, flask-extension
Flasgger
Easy OpenAPI specs and Swagger UI for your Flask API
Stars: ✭ 2,825 (+23441.67%)
Mutual labels:  flask-extensions, flask-extension
spring-boot-login-example
Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example
Stars: ✭ 50 (+316.67%)
Mutual labels:  jwt-authentication
react-redux-jwt-auth
React Redux: Token Authentication example with JWT, React Router, Axios, Thunk Middleware
Stars: ✭ 86 (+616.67%)
Mutual labels:  jwt-authentication
Auth-using-Vuejs-express-jwt-nodejs
Login and signup form and authentication using Vue.js, express, mongodb, JWT and bootstrap-vue
Stars: ✭ 17 (+41.67%)
Mutual labels:  jwt-authentication
NodeScalableArchitecture
A Scalable Node Architecture/Server. This repository contains a complete implementation of writing scalable nodejs server/architecture on my medium blog.
Stars: ✭ 62 (+416.67%)
Mutual labels:  jwt-authentication
JWTAuthNETCore3
.NET Core 3.0 (Preview 4) web API authentication demo project with password hashing and JWT Tokens
Stars: ✭ 16 (+33.33%)
Mutual labels:  jwt-authentication
spring-examples
Starter projects with Spring using Java and Kotlin. Contains modules that covers Security with JWT, Spring with Kotlin, Dependency injection simplified etc.
Stars: ✭ 33 (+175%)
Mutual labels:  jwt-authentication
online-training
Online Training website using ASP.Net Core 2.0 & Angular 4
Stars: ✭ 26 (+116.67%)
Mutual labels:  jwt-authentication
zainabed-spring-security-jwt
Authentication & Authorization module for standalone Spring Boot app or Spring Cloud applications
Stars: ✭ 24 (+100%)
Mutual labels:  jwt-authentication
express-mongo-jwt-boilerplate
Express Mongo JsonWebToken boilerplate
Stars: ✭ 100 (+733.33%)
Mutual labels:  jwt-authentication
december-2018-meetup
πŸ€– Build an API with LaravelΒ 5.7
Stars: ✭ 27 (+125%)
Mutual labels:  jwt-authentication
springboot-graphql-sqqr-jwt-demo
GraphQL java backend representing the right way to authenticate/authorize using Spring boot, graphql-spqr & jsonwebtoken
Stars: ✭ 28 (+133.33%)
Mutual labels:  jwt-authentication
socialApp-MERN
Social Networking web app similar to Instagram.
Stars: ✭ 35 (+191.67%)
Mutual labels:  jwt-authentication
flask-vuejs
Connect Flask application with VueJS
Stars: ✭ 29 (+141.67%)
Mutual labels:  flask-extensions
drf-jwt-example
Code samples of the tutorial "How to Use JWT Authentication with Django REST Framework"
Stars: ✭ 31 (+158.33%)
Mutual labels:  jwt-authentication
pothole detection
By using this app users can report the potholes on road by clicking a photo via our app and if a pothole is detected by Machine Learning modal then it is saved to our Database from where officials can view the specifics like location,reported by and official can resolve the request.User are notified by email for every update regarding their request
Stars: ✭ 17 (+41.67%)
Mutual labels:  jwt-authentication
smart-home
Control house using raspberry pi djago based secure REST api. Made using raspberry pi, arduino, django ,django REST and angular.
Stars: ✭ 30 (+150%)
Mutual labels:  jwt-authentication
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (+341.67%)
Mutual labels:  jwt-authentication

Flask-JWT-Login

Build Status Coverage Status PyPI

Flask extension that helps authentication using JWT(Json Web Token)

Guide

How to initiate

from flask import Flask
from flask_jwt_login import JWT

app = Flask(__name__)	# create app object
jwt = JWT(app)			# initialize flask_jwt_login

Configuration

app.py

from flask import Flask

app = Flask(__name__)
app.config.from_object('config.Config')

config.py

class Config(object):
    SECRET_KEY = 'random secret key for development'
    HASH_ALGORITHM = 'HS512' 
    # hash algorithm to use at encode and decode token
    JWT_COOKIE_NAME = 'token'
    # token name to be used
    
    # if you don't specify HASH_ALGORITHM or JWT_COOKIE_NAME,
    # they will have default value. (HS512 and token)

Which hash algorithm do I have to use?

Refer this link (PyJWT Documentation - Digital Signature Algorithms)

authentication

authentication handler

...
...

# initialize
jwt = JWT(app)

# user data class
# I want to recommend you to add hashed passsword data into token
class User():
	def __init__(self, id, pw, name):
		self.id = id
		self.pw = pw
		self.name = name

	def __repr__(self):
		return "User(id=%s, password=%s, name=%s)" % (self.id, self.pw, self.name)
		
# You have to write a function that check users' ids and passwords.
@jwt.authentication_handler
def authentication_handler(id, pw):
	for row in user_table:
		if row['id'] == id and row['pw'] == pw:
			return User(row['id'], row['pw'], row['name'])

	# if there is no matching user, returns None
	return None

process login

from flask_jwt_login import process_login

@app.route('/some_url')
def some_function():
	token = process_login(request.form["id"], request.form["pw"])
	# this token will be the value returned from authentication handler
	
	response = make_response("sign in")
	response.set_cookie(TOKEN_NAME, token)
	return response

unauthorized handler

@jwt.unauthorized_handler
def unauthorized_handler():
	# if authentication failed, this handler will be performed
	return 'Unauthorized Access', 501

Protected Page & User Information

login required & get current user

# this url is only accessed by users who have a valid token.
@app.route("/protected")
@login_required
def protected():
	return "Protected Page. name :" + get_current_user()["name"]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].