passport raven
1.0.0
Raven(劍橋大學)護照認證模組。
這使您可以對劍橋大學的學生進行身份驗證。
它適用於當前和過去的學生和教職員工。
npm install passport passport-raven
請參閱test/server.js
var RavenStrategy = require ( 'passport-raven' ) ;
passport . use ( new RavenStrategy ( {
desc : 'My Raven Application' ,
msg : 'we need to check you are a current student' ,
// use demonstration raven server in development
debug : process . env . NODE_ENV !== 'production'
} , function ( crsid , params , callback ) {
// You can skip this check if you want to support ex students and staff as well
if ( params . isCurrent ) {
callback ( null , { id : crsid } ) ;
} else {
callback ( new Error ( 'My Raven application is only for current students and staff' ) ) ;
}
} ) ) ;
選項:
desc
(String) - 將在 raven 登入頁面上顯示的網站描述msg
(字串)- 請求身份驗證的原因的描述iact
(布林值)- 設定為true
可以強制使用者輸入使用者false
和密碼,即使他們已經登入。預設為null
。audience
(字串)- 身份驗證請求網站的完全限定網域名稱。passReqToCallback
(Boolean) - 如果設置,請求物件將作為驗證函數的第一個參數提供。因此,驗證回呼可以使用請求的狀態來進行進一步的處理。 passport . use ( new RavenStrategy ( {
desc : 'My Raven Application' ,
msg : 'we need to check you are a current student' ,
// use demonstration raven server in development
debug : process . env . NODE_ENV !== 'production' ,
passReqToCallback : true
} , function ( req , crsid , params , callback ) {
// this function could be defined elsewhere eg in a Sails app services protocol
... .
}
} ) ;
`
參數:
params 包含從伺服器傳回的所有訊息,這裡有兩個範例:
目前的學生/教職員:
{ ver: '3',
status: '200',
msg: '',
issue: '20141007T144208Z',
id: '1412692928-14998-17',
url: 'http://localhost:3000/login',
principal: 'test0001',
ptags: 'current',
auth: 'pwd',
sso: '',
life: '36000',
params: '',
kid: '901',
sig: 'qEK1GusOfnfh6D8BkmTi2iIsEXLmrfOd2TMEXStedOgaDXF7BQnN1nQvD8mudXhLO-rDLhp3JetrAded1XNeNaJPwdU5ZNIf5bJrvln2iqwbY280B4nGusvcOQjDoD1UJQ-J3hEpTDe7miDzGwSB-7zvdkpzt56qPgmUIIYHWs4_',
isCurrent: true }
過去的學生/教職員工:
{ ver: '3',
status: '200',
msg: '',
issue: '20141007T144128Z',
id: '1412692886-14816-35',
url: 'http://localhost:3000/login',
principal: 'test0450',
ptags: '',
auth: '',
sso: 'pwd',
life: '35960',
params: '',
kid: '901',
sig: 'otTWl-KZbXbRUMLjwpkoiT.nu8J7GnoHu6V8JzXjAu.XPGBBxRAJXEzCEQfc05jcoFmGWdHWPLjmJgNgom2vnltCu-CZOlAd9105v-k.9.dZQJAc65ugIlHDvPPT2icXiT1zo9.wzkCA.5vwLeUrhA8oKAa-6cuxbbzkwH-.Cc8_',
isCurrent: false }
app . get ( '/auth/raven' , passport . authenticate ( 'raven' ) , function ( req , res ) {
// Successful authentication, redirect home.
res . redirect ( '/' ) ;
} ) ;
麻省理工學院