2017-05-10 17 views
1

OIDCStrategyの複数のポリシーを同じアプリケーション内に含めることはできますか。 私は によって認証される必要があるアプリケーションをApp1(ClientID1)またはApp2(ClientId2)を通じて提供しています。passport-azure-adを使用したOIDCStrategyの複数のポリシー

Passport-Azure-Ad OIDCStrategyを使用している場合、私は常にそのうちの1つだけで認証されています。ここで構成された戦略がある

app.get('/login1', 
    passport.authenticate('azuread-openidconnect', { failureRedirect: '/' }), 
    .... 
}); 

app.post('/auth/openid/return1', 
    passport.authenticate('azuread-openidconnect', { failureRedirect: '/' }), 
    function(req, res) { 
    ... 
    }); 

app.get('/login2', 
    passport.authenticate('azuread-openidconnect', { failureRedirect: '/' }), 
    .... 
}); 

app.post('/auth/openid/return2', 
    passport.authenticate('azuread-openidconnect', { failureRedirect: '/' }), 
    function(req, res) { 
    ... 
    }); 

はここでルートです。

passport.use(new OIDCStrategy({ 
    clientID: config.creds.clientID1, 
    redirectUrl: config.creds.redirectUrl1, 
    clientSecret: config.creds.clientSecret1, 
... 
}); 


passport.use(new OIDCStrategy({ 
    clientID: config.creds.clientID2, 
    redirectUrl: config.creds.redirectUrl2, 
    clientSecret: config.creds.clientSecret2, 
... 
}); 

アップデート:これはpassport-azure-adからサポートされていません。 深く入り込んで確認しました。新しい戦略を追加すると、実際には "azuread-openidconnect"というキーを追加する戦略 別の戦略を追加すると、その戦略を上書きします。

passport._strategies['azuread-openidconnect'] 

これは、最新のものを使用しています。

まだ複数のAADアプリケーションでアプリケーションを認証する必要があるという私のシナリオに対する解決策がありますか? ?

解決策はこれまでのところです:マルチテナントAADアプリケーションを登録し、テナントを私たちが望むものに制限する必要があります。

+0

私の理解に基づいて、複数のAzure ADアプリケーションを登録するのが適切なソリューションです。この解決策が満たせないという別の要件がありますか? –

答えて

0

2つの戦略を作成し、それらの名前を上書きしてから、その戦略をpassport.authenticateで指定することができます。この方法は私のために働く。

var strategy1 = new OIDCStrategy(...); 
strategy1.name = "strategy1"; 

var strategy2 = new OIDCStrategy(...); 
strategy2.name = "strategy2"; 

passport.use('strategy1'); 
passport.use('strategy2'); 

app.get('/login1', passport.authenticate('strategy1', ...)); 

app.post('/auth/openid/return1', passport.authenticate('strategy1', ...)); 

app.get('/login2', passport.authenticate('strategy2', ...)); 

app.post('/auth/openid/return2', passport.authenticate('strategy2', ...)); 
関連する問題