session-less use of jwt and passport.js
note: by module I mean either a javascript (.js) or coffeescript (.coffee) file
install the following:
- sailsjs
Single Page Apps are ruling the world and AngularJS is leading the charge. But many of the lessons we learned in the Web 2.0 era no longer apply, and few are as drastically different as authentication.
CORS is an oft-misunderstood feature of new browsers that is configured by a remote server. CORS stands for Cross-Origin-Resource-Sharing, and was designed to make it possible to access services outside of the current origin (or domain) of the current page.
Like many browser features, CORS works because we all agree that it works. So all major browsers like Chrome, Firefox, and IE support and enforce it. By using these browsers, you benefit from the security of CORS.
That means certain browsers do not enforce it, so it is not relevant there. One large example is a native Web View for things like Cordova and Phonegap. However, these tools often have configuration options for whitelisting domains so you can add some security that way.
| var phonecatAnimations = require("./animations.js"); | |
| var phonecatControllers = require("./controllers.js"); | |
| var phonecatFilters = require("./filters.js"); | |
| var phonecatServices = require("./services.js"); | |
| 'use strict'; | |
| /* App Module */ | |
| var phonecatApp = angular.module('phonecatApp', [ |
| app.factory('ArrayService', function(){ | |
| return { | |
| deleteElement: function(array, element) { | |
| var index = array.indexOf(element); | |
| if(index == -1){ | |
| return false; | |
| } | |
| array.splice(index, 1); |
| /*global chrome*/ | |
| var EventEmitter = require('./events.js').EventEmitter; | |
| var util = require('./util.js'); | |
| function SerialPort(port, options) { | |
| var self = this; | |
| var id; | |
| var bytesToRead = options.buffersize || 1; |
| 'use strict'; | |
| /** | |
| * @ngdoc module | |
| * @name sails.io | |
| * @file angular-sails-io.js | |
| * | |
| * @description | |
| * | |
| * This file allows you to send and receive socket.io messages to & from Sails |
| // Define gulp before we start | |
| var gulp = require('gulp'); | |
| // Define Sass and the autoprefixer | |
| var sass = require('gulp-sass'); | |
| var prefix = require('gulp-autoprefixer'); | |
| // This is an object which defines paths for the styles. | |
| // Can add paths for javascript or images for example | |
| // The folder, files to look for and destination are all required for sass |
| #!/bin/bash | |
| # | |
| # description: DevShelf service | |
| # processname: node | |
| # pidfile: /var/run/devshelf.pid | |
| # logfile: /var/log/devshelf.log | |
| # | |
| # Based on https://gist.github.com/jinze/3748766 | |
| # | |
| # To use it as service on Ubuntu: |
| angular.module("MyApp", ["SocketProvider"]) | |
| .controller("MyController", ["$scope", "socket", function($scope, socket) { | |
| // Fetch initial data | |
| $scope.person = null; | |
| socket.get("/person/1").success(function(data) { | |
| $scope.person = data; | |
| }).error(function() { |