Skip to content

Instantly share code, notes, and snippets.

View HAKASHUN's full-sized avatar
🍊
みかん食べてる

HAKASHUN HAKASHUN

🍊
みかん食べてる
View GitHub Profile
@samsch
samsch / stop-using-jwts.md
Last active April 23, 2024 05:47
Stop using JWTs

Stop using JWTs!

TLDR: JWTs should not be used for keeping your user logged in. They are not designed for this purpose, they are not secure, and there is a much better tool which is designed for it: regular cookie sessions.

If you've got a bit of time to watch a presentation on it, I highly recommend this talk: https://www.youtube.com/watch?v=pYeekwv3vC4 (Note that other topics are largely skimmed over, such as CSRF protection. You should learn about other topics from other sources. Also note that "valid" usecases for JWTs at the end of the video can also be easily handled by other, better, and more secure tools. Specifically, PASETO.)

A related topic: Don't use localStorage (or sessionStorage) for authentication credentials, including JWT tokens: https://www.rdegges.com/2018/please-stop-using-local-storage/

The reason to avoid JWTs comes down to a couple different points:

  • The JWT specification is specifically designed only for very short-live tokens (~5 minute or less). Sessions
@jamesknelson
jamesknelson / component-routing.js
Last active March 19, 2019 11:22
Two APIs for routing with React that support POST methods and SSR.
/**
UPDATE:
This component and hook based routing/fetching API won't work, as `useAsync()`
is an impossible component.
In order to use async functions to respond to route changes, the functions will
need to be registered with a parent cache/provider with a unique key. As such, a
more natural component-based architecture would involve a `<Route path>` component
@gpeal
gpeal / SimpleDemo.kt
Last active August 28, 2018 17:54
Airbnb MvRx Early Look
data class SimpleDemoState(val listing: Async<Listing> = Uninitialized)
class SimpleDemoViewModel(override val initialState: SimpleDemoState) : MvRxViewModel<SimpleDemoState>() {
init {
fetchListing()
}
private fun fetchListing() {
// This automatically fires off a request and maps its response to Async<Listing>
// which is a sealed class and can be: Unitialized, Loading, Success, and Fail.
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)
@FranklinYu
FranklinYu / README.markdown
Last active May 5, 2024 15:24
links for old versions of Docker for Mac (inspired by docker/for-mac#1120)

links for old versions of Docker for Mac

Deprecated

Docker provides download links in release note. They promised that

(we) will also include download links in release notes for future releases.

Note:

@heygambo
heygambo / dev.env.js
Created October 27, 2016 20:06
Environment variables for vue webpack frontends
// src/config/dev.env.js
export default {
GOOGLE_MAPS_API_KEY: 'THE KEY'
}
@onevcat
onevcat / localizedKey.swift
Created October 21, 2015 08:33
Extension
extension UILabel {
@IBInspectable var localizedKey: String? {
set {
if let s = newValue {
text = NSLocalizedString(s, comment:"")
}
}
get {
return text
@harrastia
harrastia / decorator
Last active August 29, 2015 14:21 — forked from zourtney/decorator
Adapted decorator to work in Angular 1.3.8
// Decorator adapted out of Angular 1.3.8
// https://github.com/angular/angular.js/blob/v1.3.8/src/ng/rootScope.js#L196
.config(['$provide', function($provide) {
// Minification-safe hack.
var $$watchers = '$$watchers',
$$nextSibling = '$$nextSibling',
$$childHead = '$$childHead',
$$childTail = '$$childTail',
$$listeners = '$$listeners',