我试图在我的Meteor项目中实施passport.js,我很难通过护照发送用户信息.
首先,我正在构建一个在组织一侧使用LDAP的身份验证系统.你已经购买了Shibboleth的身份提供商,http: //shibboleth.net/products/identity-provider.html,并希望使用passport-saml作为驻留在web应用程序中的身份验证框架.我已经关注了这个git教程,https://github.com/bergie/passport-saml,以及官方的passport.js教程,我已经在Meteor服务器端的passport.js中实现了这些方法.
Meteor.startup(function () {
var require = Npm.require;
passport = require('passport');
var SamlStrategy = require('passport-saml').Strategy;
passport.use(new SamlStrategy(
{
path: '/login/callback',
entryPoint: 'https://openidp.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'passport-saml'
},
function(profile, done) {
findByEmail(profile.email, function(err, user) {
if (err) {
return done(err);
}
return done(null, user);
});
}
));
Meteor.Router.add('/login/callback', 'POST', function(req, res){
passport.authenticate('saml', { failureRedirect: '/', failureFlash: true });
res.redirect('/');
});
Meteor.Router.add('/login', 'POST', function(req, res){
passport.authenticate('saml', { failureRedirect: '/', failureFlash: true });
res.redirect('/');
});
var app = __meteor_bootstrap__.app;
app.use(passport.initialize()); …Run Code Online (Sandbox Code Playgroud) 我已经按照collectionFS指南和其他几个stackoverflow问题[这里] [1],但我仍然在显示图像时遇到错误.显示损坏的图像图标,控制台打印"资源解释为图像,但使用MIME类型text/html传输:".知道我能做些什么来解决这个问题?
我的代码如下:
HTML
<template name="fileList">
{{#each images}}
{{name}}
<img src="{{cfsFileUrl 'default1'}}">
<br />
{{else}}
No Files uploaded
{{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)
客户端JS
Template.fileList.helpers({
'images': function(){
return ImagesFS.find({}, {sort: {uploadDate:-1}});
}
});
Run Code Online (Sandbox Code Playgroud)
服务器JS
if(Meteor.isServer){
ImagesFS.fileHandlers({
default1: function(options) { // Options contains blob and fileRecord — same is expected in return if should be saved on filesytem, can be modified
console.log('I am handling default1: ' + options.fileRecord.filename);
console.log(options.destination());
return { blob: options.blob, fileRecord: options.fileRecord }; // if no blob then save result in …Run Code Online (Sandbox Code Playgroud)