diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9daa824 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.DS_Store +node_modules diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..d9ceb36 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +*.md +.DS_Store +.git* +Makefile +docs/ +examples/ +support/ +test/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74524ce --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +(The MIT License) + +Copyright (c) 2011 Jared Hanson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..28d9ce7 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +NODE = node +TEST = vows +TESTS ?= test/*-test.js test/**/*-test.js + +test: + @NODE_ENV=test NODE_PATH=lib $(TEST) $(TEST_FLAGS) $(TESTS) + +docs: docs/api.html + +docs/api.html: lib/passport-twitter/*.js + dox \ + --title Passport-Twitter \ + --desc "Twitter authentication strategy for Passport" \ + $(shell find lib/passport-twitter/* -type f) > $@ + +docclean: + rm -f docs/*.{1,html} + +.PHONY: test docs docclean diff --git a/README.md b/README.md new file mode 100644 index 0000000..b668bfb --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Passport-OAuth + +[Passport](https://github.com/jaredhanson/passport) strategy for authenticating +with Twitter using the OAuth 1.0a API. + +## License + +(The MIT License) + +Copyright (c) 2011 Jared Hanson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/lib/passport-twitter/index.js b/lib/passport-twitter/index.js new file mode 100644 index 0000000..0674818 --- /dev/null +++ b/lib/passport-twitter/index.js @@ -0,0 +1,15 @@ +/** + * Module dependencies. + */ +var Strategy = require('./strategy'); + + +/** + * Framework version. + */ +exports.version = '0.1.0'; + +/** + * Expose constructors. + */ +exports.Strategy = Strategy; diff --git a/lib/passport-twitter/strategy.js b/lib/passport-twitter/strategy.js new file mode 100644 index 0000000..f412cc4 --- /dev/null +++ b/lib/passport-twitter/strategy.js @@ -0,0 +1,32 @@ +/** + * Module dependencies. + */ +var util = require('util') + , OAuthStrategy = require("passport-oauth").OAuthStrategy; + + +/** + * `Strategy` constructor. + * + * @api public + */ +function Strategy(options, validate) { + options = options || {}; + options.requestTokenURL = options.requestTokenURL || 'https://twitter.com/oauth/request_token'; + options.accessTokenURL = options.accessTokenURL || 'https://twitter.com/oauth/access_token'; + options.userAuthorizationURL = options.userAuthorizationURL || 'https://twitter.com/oauth/authenticate'; + + OAuthStrategy.call(this, options, validate); + this.name = 'twitter'; +} + +/** + * Inherit from `OAuthStrategy`. + */ +util.inherits(Strategy, OAuthStrategy); + + +/** + * Expose `Strategy`. + */ +module.exports = Strategy; diff --git a/package.json b/package.json new file mode 100644 index 0000000..8ee9032 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "passport-twitter", + "version": "0.1.0", + "description": "Twitter authentication strategy for Passport.", + "author": "Jared Hanson (http://www.jaredhanson.net/)", + "repository": { + "type": "git", + "url": "http://github.com/jaredhanson/passport-twitter.git" + }, + "main": "./lib/passport-twitter", + "dependencies": { + "passport-oauth": ">= 0.0.1" + }, + "engines": { "node": ">= 0.4.0" }, + "keywords": ["passport", "twitter", "auth", "authn", "authentication"] +}