Skip to content

Instantly share code, notes, and snippets.

@marshallswain
Last active November 11, 2016 18:59
Show Gist options
  • Save marshallswain/6ccaf2a7a1b1fc0f0eacd0b1796889f5 to your computer and use it in GitHub Desktop.
Save marshallswain/6ccaf2a7a1b1fc0f0eacd0b1796889f5 to your computer and use it in GitHub Desktop.
Bitcentive Guide

Bitcentive

High Level Architecture

Server and Services

  • Feathers
  • feathers-mongoose
    • only used for the model validation
  • MongoDB
  • Session Management: feathers-authentication
    • Loosely using the word “session” feels fine unless you have experience with sessions on the server.

donejs-feathers generator

  • Too much tech debt here, now. I agree, for different reasons, that we probably shouldn't mention it at all.
  • We started with the generator.
  • Puts everything that the client app needs in place with one cli command.
  • High level explanation of what we modified. (not much)
  • Generator Tech Debt
    • Needs to be updated to use the new modules
      • feathers-client
    • can-connect-feathers behaviors
    • feathers-authentication-popups
    • feathers-socketio-ssr
    • auth-component
      • Not currently being used in Bitcentive, but we could, now that we’ve removed username/password auth. We can easily explain that it only opens a popup window.
      • It’s built to be feathers-compatible by default. Maybe I should generalize the main one and make a feathers-specific one available in the same package.
    • can-fixture-socket
    • steal-socket.io
  • With this much tech debt / delay, we probably shouldn’t even mention the generator.

GitHub Auth

Client popup flow

  • Client: Open popup window
    • feathers-authentication-popups openLoginPopups()
  • Server: direct popup to GitHub login window with configuration data on the server.
    • feathers-authentication OAuth2 plugin
  • Client: User grants access
  • Server: middleware to handle popup returns a pre-made page to handle the success response
    • feathers-authentication-popups express.js middleware
  • Client: popup window sends “session” data (JWT) to the parent window.
    • feathers-authentication-popups window.authAgent
  • Client: Event streams in the main window respond to the session data
    • can-stream
  • We get a JWT back in this process, let’s talk about JWTs, now.

JWTs

Feathers uses them

High level overview of JWTs

  • Explaining the in a way that’s easy to understand is difficult.
  • Give basic overview and provide links out to good sources for more information.
  • We could get into the weeds and talk security
    • How we avoid CSRF vulnerabilities while still using cookies.
    • This would probably serve better as its own blog article with the diagrams that I made.

SSR

A lot is already covered in the BitBalls guide, so we can cover Feathers-specific information.

  • feathers-socketio-ssr
    • Switches between Socket.io on the client and XHR requests on the server.
      • Made possible because Feathers uses a common query syntax across multiple transports
  • steal-socket.io
    • Prevents the server from opening the socket connection on the SSR server.
  • done-ssr / can-zone plugin?
    • For the client, intercept native WebSockets and return cached requests from SSR server’s XHR_CACHE
  • done-ssr JWT proxy

Fixturizing WebSockets

can-fixture-socket

steal-socket.io

How to use socket fixtures in

  • Tests
  • Demos

Enhancing your connection with custom can-connect behaviors

connected define-maps

can-connect-feathers

  • killer real-time features

Nested model relationships

canRef

ContributionMonth uses

  • MonthlyOSProject
  • MonthlyClientProject
  • MonthlyContributions

Permissions / Access Control

How we used the JWT payload combined with feathers hooks to lock down the API server.

What is our required permissions setup / groups, etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment