passport

Flask: SSO原理及实现

雨燕双飞 提交于 2019-12-04 02:11:15
现在大多数软件公司的业务不再是单条线,而是发展成多元化的产品线。包括多个网站应用、移动APP以及桌面软件,那么当然希望能实现统一用户和统一登录。统一用户基本都已实现,然而统一登录却还是有不少公司未予以实现。这倒不是说SSO有多复杂或多难实现,这其中可能有历史遗留问题也或是其它原因。这是题外话,本文不作深究。 什么是统一用户 统一用户指的是多个应用共用一套帐号体系。比如Z公司旗下有aw和bw两个网站,有帐号goal,那么使用帐号goal能登录aw和bw。这个在技术上也不难实现,通常来说有2个方案: 共享持久层 这是最常用的方式。aw和bw通过直接访问同一个后端数据库来达到数据共享。 通过代理访问 这种方式类似于通过网关来访问同一个后端数据库。本质上跟共享持久层是一样的,无外乎多了层网关,这样是有好处的,本文接下来会涉及到。 这看起来好像够了,但是请您考虑这样一个场景:aw和bw是两个不同的网页游戏,那么首先aw和bw都有自己的激活流程,然后有自己的游戏角色、装备等各种属性。所以aw和bw应该有各自的profile。对此我归纳了几下几点: 统一用户帐号表仅保存各个应用的公共属性,其它应用可以重写这些属性 应该能标识出是否已激活过 应该能标识出属于哪个应用 对于第一点,这没什么好说的。第二点和第三点可以分别用一个整型字段来表示,属性存储在不同的位上,而且一般都是这么做的。如下代码所示:

在多版本php环境,指定composer使用的php版本

你。 提交于 2019-12-03 11:50:51
在不同的项目中,可能会使用不同的php版本,在使用 composer 安装依赖时,如何指定不同的php版本呢? 比如平时开发时,使用的是 php 7.0版本,但是在按照 Laravel最新版本(5.6) 时就跑不同了。因为在Laravel 5.6中, 最低要求版本是 PHP 7.1.3. 查看默认PHP版本: 本机中默认PHP版本是7.0.30,命令地址是“/usr/local/bin/php”。 $ which php /usr/local/bin/php $ /usr/local/bin/php -v PHP 7.0.30 (cli) (built: Jun 22 2018 00:52:06) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.30, Copyright (c) 1999-2017, by Zend Technologies 安装PHP 7.2 在macOS系统中使用brew软件管理工具安装: $ brew search php72 $ brew install php72 // 将命令路径复制一份到环境变量目录里: $ cp /usr/local

Laravel Passport vs JWT vs Oauth2 vs Auth0

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Confusion about API auth types in Laravel? I'm currently learning how to create an API in Laravel and I found myself into this confusing concepts. After a few days of research and practice, I could finally understand enough this concepts to make a mini-guide. I had to look into a lot of separate webpages so I will make my best attempt to explain the relationship between them. 回答1: What are these concepts? Passport is a official Laravel package that implements Oauth2 and JWT. Auth0 is a authentication and authorization service. It is kinda

Passport authenticate callback is not passed req and res

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: this authenticate works fine and I get a redirect: server.post(authPostRoute, passport.authenticate( 'local' , { successRedirect: '/', failureRedirect: '/login' } )); this authenticate hangs after the call back is called: server.post(authPostRoute, passport.authenticate( 'local' , function(){ console.log('Hitting the callback'); console.log(arguments)} )); this logs the following piece: { '0': null, '1': { id: [Getter/Setter], firstName: [Getter/Setter], lastName: [Getter/Setter], email: [Getter/Setter], addedOn: [Getter/Setter], active:

Passport local strategy and cURL

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to test my node.js + express + passport.js test application (RESTful) with CURL. My code: var express = require ( 'express' ); var routes = require ( './routes' ); var http = require ( 'http' ); var path = require ( 'path' ); var passport = require ( 'passport' ); var LocalStrategy = require ( 'passport-local' ). Strategy ; // Define the strategy to be used by PassportJS passport . use ( new LocalStrategy ( function ( username , password , done ) { if ( username === "admin" && password === "admin" ) // stupid example

Error: failed to find request token in session

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I found a few issues on the main passport repo, however, I think this primarily pertains to this specific strategy as I'm able to successfully authenticate using the passport-google-oauth strategy. Error: failed to find request token in session at Strategy.OAuthStrategy.authenticate (/home/glug/application/node_modules/passport-dropbox/node_modules/passport-oauth/lib/passport-oauth/strategies/oauth.js:124:54) at attempt (/home/glug/application/node_modules/passport/lib/passport/middleware/authenticate.js:243:16) at Passport.authenticate (

CORS - Facebook - Passport

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to implement OAUTH login via Facebook in my Nodejs/Angular/Express/Passport app but i'm struggeling with it. I still get the CORS error: XMLHttpRequest has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' https://www.xxxxxx.net ' is therefore not allowed access. Although i already added to my EXPRESS ROUTER: router.all('/*', function(req, res, next) { res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');

passport.js passport.initialize() middleware not in use

匿名 (未验证) 提交于 2019-12-03 02:14:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using node with express + mongoose and trying to use passport.js with restful api. I keep getting this exception after authentication success (I see the callback url on the browser): /Users/naorye/dev/naorye/myproj/node_modules/mongoose/lib/utils.js:419 throw err; ^ Error: passport.initialize() middleware not in use at IncomingMessage.req.login.req.logIn (/Users/naorye/dev/naorye/myproj/node_modules/passport/lib/passport/http/request.js:30:30) at Context.module.exports.delegate.success (/Users/naorye/dev/naorye/myproj/node_modules

Passport js local strategy custom callback showing user as false and info as “Missing credentials”

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using Node.js,angularjs,express and passport. I have tried all options I can think of, but still no solution. Couldn't find a solution from other posts for this problem. app.post('/login', function(req, res, next) { console.log(req.body.Email); console.log(req.body.Password); passport.authenticate('local', function(err, user, info) { console.log(err,user,info); ... In above req.body is showing correct in console but in passport authenticate it is showing null,false and info as missing credentials. I have used the following for pass port

单点登录 - API 认证系统 Passport(二)

女生的网名这么多〃 提交于 2019-12-03 01:46:32
安装 composer require laravel/passport=~4.0 notes: 1)确保系统安装unzip、zip等命令。 2)composer 安装出现 Authentication required (packagist.phpcomposer.com) 问题,修改composer.json 中的源,repositories.packagist.url = https://packagist.laravel-china.org 。 注册服务提供者 在config/app.php的providers 数组中加入 Laravel\Passport\PassportServiceProvider::class 迁移数据库 php artisan migrate //生成用于存储客户端和令牌的数据表 生成加密健 php artisan passport:install 1、生成oauth-private.key(用于构建认证服务器),oauth-public.key(用于构建资源服务器) 2、oauth_clients数据库生成「个人访问」客户端和「密码授权]两条数据。 配置Passport(参考官方文档) 在Model中,我们需要增加 HasApiTokens class 在AuthServiceProvider中, 增加 "Passport::routes()"