Pablo Carranza Vélez
Published

Safe Deposit Box with two-factor authentication

A safe-deposit box that requires 2FA to open. Built with resin.io and Authy.

IntermediateFull instructions provided7,665
Safe Deposit Box with two-factor authentication

Things used in this project

Hardware components

Raspberry Pi 2 Model B
Raspberry Pi 2 Model B
×1
A rather hard-to-break box
Be careful to choose one with a large enough opening for the Pi’s power cable as well as sufficient space so that the solenoid can be attached such that it blocks the door when it's closed.
×1
A small protoboard
×1
Resistors
We used three 10 ohm resistors in parallel to obtain 3.3 ohms resistance (which we recommend to have a greater max current) and two 470 ohm resistors to obtain 235 ohms for R2 (though here a single 220 ohms would work)
×6
1N4148 diode
×1
2N2222 transistor
×1
Assorted protoboard wires
Male-male and male-female
×1
5V Solenoid
https://www.sparkfun.com/products/11015
×1

Software apps and online services

Upverter
Upverter
balenaCloud
balenaCloud

Story

Read more

Schematics

Upverter

https://upverter.com/pcarranzav/064ec0097922e63c/Solenoid-driver/

Solenoid driver

Code

Code

Plain text
var safebox = new machina.Fsm({
    /* ... other properties here */
    states: {
        /* ... other states here and below */
        closed: {
            _onEnter: function(){
                this.lock.enabled(false);
                this.lock.close();
                this.persistedState.currentState = 'closed';
                this.persistedState.save();
                this.emitStatus();
            },
            input: function(data){
                this.currentUser.comparePassword(data.code, function(err, match){
                    if(match){
                        safebox.transition('authenticating');
                    } else {
                        io.emit('notice', 'That\'s not your code!');
                        safebox.transition('closed');
                    }
                });
            }
        },
        /* ... */
    }
});

Code

Plain text
FROM resin/rpi-raspbian:jessie
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y build-essential nodejs mongodb
COPY . .
RUN mkdir -p /datadb
RUN npm install
EXPOSE 8080
CMD bash start.sh

Github

https://github.com/resin-io/resin-safebox

Github

https://github.com/ifandelse/machina.js/

Github

https://github.com/TwilioDevEd/authy2fa-node

Github

https://github.com/CodeSeven/toastr

Credits

Pablo Carranza Vélez

Pablo Carranza Vélez

2 projects • 15 followers

Comments