वेब ऐप्लिकेशन में एसएएमएल का इस्तेमाल करके पुष्टि करें
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
अगर आपने Firebase Authentication with Identity Platform पर अपग्रेड किया है, तो Firebase की मदद से अपने उपयोगकर्ताओं की पुष्टि की जा सकती है
अपनी पसंद के एसएएमएल आइडेंटिटी प्रोवाइडर का इस्तेमाल करके. इससे हमें अलग-अलग प्लैटफ़ॉर्म का इस्तेमाल करने में आसानी होती है.
आपके Firebase ऐप्लिकेशन में उपयोगकर्ताओं को साइन इन करने के लिए, एसएएमएल पर आधारित एसएसओ (SSO) समाधान का इस्तेमाल करें.
Firebase Authentication सिर्फ़ सेवा देने वाली कंपनी के शुरू किए गए एसएएमएल फ़्लो के साथ काम करता है.
शुरू करने से पहले
किसी एसएएमएल आइडेंटिटी प्रोवाइडर की मदद से साइन इन करने के लिए, आपको पहले कुछ जानकारी इकट्ठा करनी होगी
कंपनी से मिली जानकारी:
- सेवा देने वाली कंपनी का इकाई आईडी: एक यूआरआई जो आइडेंटिटी प्रोवाइडर की पहचान करता है.
- सेवा देने वाली कंपनी का एसएएमएल एसएसओ (SSO) यूआरएल: आइडेंटिटी प्रोवाइडर के साइन इन का यूआरएल
करें.
- सेवा देने वाले का सार्वजनिक पासकोड का सर्टिफ़िकेट: वह सर्टिफ़िकेट जिसका इस्तेमाल पुष्टि करने के लिए किया जाता है
टोकन.
- आपके ऐप्लिकेशन का इकाई आईडी: एक यूआरआई जो आपके ऐप्लिकेशन, "सेवा" की पहचान करता है
कंपनी".
ऊपर दी गई जानकारी मिलने के बाद, एसएएमएल को साइन इन सेवा देने वाली कंपनी के तौर पर चालू करें
Firebase प्रोजेक्ट:
Firebase को अपने JavaScript प्रोजेक्ट में जोड़ें.
अगर आपने Firebase Authentication with Identity Platform पर अपग्रेड नहीं किया है, तो ऐसा करें. एसएएमएल पुष्टि सिर्फ़
उपलब्ध है.
साइन-इन करने की सुविधा देने वाली कंपनियों पर
Firebase कंसोल के पेज पर जाएं, नई कंपनी जोड़ें पर क्लिक करें और फिर
एसएएमएल.
इस कंपनी को एक नाम दें. जनरेट किए गए, सेवा देने वाले के आईडी को नोट करें:
saml.example-provider
जैसा कुछ. खातों को जोड़ते समय आपको इस आईडी की ज़रूरत होगी
अपने ऐप्लिकेशन में साइन-इन कोड डालें.
अपने आइडेंटिटी प्रोवाइडर का इकाई आईडी, एसएसओ (SSO) यूआरएल, और सार्वजनिक पासकोड बताएं
प्रमाणपत्र. अपने ऐप्लिकेशन (सेवा देने वाली कंपनी) का इकाई आईडी भी बताएं.
ये वैल्यू, उन वैल्यू से पूरी तरह मेल खानी चाहिए जो आपको सेवा देने वाली कंपनी ने असाइन की हैं.
बदलावों को सेव करें.
अगर आपने पहले से अपने ऐप्लिकेशन के डोमेन को अनुमति नहीं दी है, तो उसे अनुमति वाले डोमेन में जोड़ें
की सूची दिखेगी.पुष्टि करने की प्रक्रिया > सेटिंग
पेज Firebase कंसोल का.
Firebase SDK टूल की मदद से साइन-इन की प्रोसेस को मैनेज करना
Firebase JavaScript SDK टूल से साइन-इन फ़्लो को मैनेज करने के लिए, इन निर्देशों का पालन करें
चरण:
आपको जो प्रोवाइडर आईडी मिला है उसका इस्तेमाल करके, SAMLAuthProvider
का इंस्टेंस बनाएं
Firebase कंसोल.
Web
import { SAMLAuthProvider } from "firebase/auth";
const provider = new SAMLAuthProvider('saml.example-provider');
Web
var provider = new firebase.auth.SAMLAuthProvider('saml.example-provider');
``
एसएएमएल प्रोवाइडर ऑब्जेक्ट का इस्तेमाल करके, Firebase से पुष्टि करें.
उपयोगकर्ता को या तो सेवा देने वाली कंपनी के साइन-इन पेज पर रीडायरेक्ट किया जा सकता है या
पॉप-अप ब्राउज़र विंडो में साइन-इन पेज पर.
रीडायरेक्ट फ़्लो
signInWithRedirect()
पर कॉल करके, सेवा देने वाली कंपनी के साइन-इन पेज पर रीडायरेक्ट करें:
Web
import { getAuth, signInWithRedirect } from "firebase/auth";
const auth = getAuth();
signInWithRedirect(auth, provider);
Web
firebase.auth().signInWithRedirect(provider);
उपयोगकर्ता के साइन-इन करने और आपके ऐप्लिकेशन पर वापस लौटने के बाद, आपको
getRedirectResult()
पर कॉल करके साइन-इन परिणाम.
Web
import { getAuth, getRedirectResult, SAMLAuthProvider } from "firebase/auth";
const auth = getAuth();
getRedirectResult(auth)
.then((result) => {
// User is signed in.
// Provider data available using getAdditionalUserInfo()
})
.catch((error) => {
// Handle error.
});
Web
firebase.auth().getRedirectResult()
.then((result) => {
// User is signed in.
// Provider data available in result.additionalUserInfo.profile,
// or from the user's ID token obtained from result.user.getIdToken()
// as an object in the firebase.sign_in_attributes custom claim.
})
.catch((error) => {
// Handle error.
});
पॉप-अप फ़्लो
Web
import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth";
const auth = getAuth();
signInWithPopup(auth, provider)
.then((result) => {
// User is signed in.
// Provider data available in result.additionalUserInfo.profile,
// or from the user's ID token obtained from result.user.getIdToken()
// as an object in the firebase.sign_in_attributes custom claim.
})
.catch((error) => {
// Handle error.
});
Web
firebase.auth().signInWithPopup(provider)
.then((result) => {
// User is signed in.
// Provider data available in result.additionalUserInfo.profile,
// or from the user's ID token obtained from result.user.getIdToken()
// as an object in the firebase.sign_in_attributes custom claim.
})
.catch((error) => {
// Handle error.
});
आईडी टोकन और UserInfo
ऑब्जेक्ट में उपयोगकर्ता का ईमेल पता सिर्फ़ तब शामिल होता है, जब वह
पहचान देने वाली सेवा से मिलने वाले एसएएमएल दावे का NameID
एट्रिब्यूट:
<Subject>
<NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">test@email.com</NameID>
</Subject>
ऊपर दिए गए उदाहरण, साइन-इन करने के फ़्लो पर फ़ोकस करते हैं. हालांकि, इनका इस्तेमाल भी किया जा सकता है
ताकि एसएएमएल सेवा देने वाली कंपनी को किसी मौजूदा उपयोगकर्ता से लिंक किया जा सके
linkWithRedirect()
और linkWithPopup()
. साथ ही, इस सुविधा का इस्तेमाल करके किसी उपयोगकर्ता की फिर से पुष्टि करें
reauthenticateWithRedirect()
और reauthenticateWithPopup()
इनमें से कोई भी हो सकता है.
इसका इस्तेमाल, संवेदनशील कार्रवाइयों के लिए नए क्रेडेंशियल हासिल करने के लिए किया जाता है.
हाल ही का लॉगिन.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-08 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-08 (UTC) को अपडेट किया गया."],[],[],null,["If you've upgraded to Firebase Authentication with Identity Platform, you can authenticate your users with Firebase\nusing the SAML identity provider of your choice. This makes it possible to use\nyour SAML-based SSO solution to sign users in to your Firebase app.\n\nFirebase Authentication supports only the service-provider initiated SAML flow.\n\nBefore you begin\n\nTo sign in users using a SAML identity provider, you must first collect some\ninformation from the provider:\n\n- **The provider's Entity ID**: A URI that identifies the identity provider.\n- **The provider's SAML SSO URL**: The URL of the identity provider's sign-in page.\n- **The provider's public key certificate**: The certificate used to validate tokens signed by the identity provider.\n- **Your app's Entity ID**: A URI that identifies your app, the \"service provider\".\n\nAfter you have the above information, enable SAML as a sign-in provider for your\nFirebase project:\n\n1. [Add Firebase to your JavaScript project](/docs/web/setup).\n\n2. If you haven't upgraded to Firebase Authentication with Identity Platform, do so. SAML authentication is only\n available in upgraded projects.\n\n3. On the [**Sign-in providers**](//console.firebase.google.com/project/_/authentication/providers)\n page of the Firebase console, click **Add new provider** , and then click\n **SAML**.\n\n4. Give a name to this provider. Note the provider ID that's generated:\n something like `saml.example-provider`. You'll need this ID when you add\n sign-in code to your app.\n\n5. Specify your identity provider's entity ID, SSO URL, and public key\n certificate. Also specify the entity ID of your app (the service provider).\n These values must exactly match the values your provider assigned to you.\n\n6. Save your changes.\n\n7. If you haven't already authorized your app's domain, add it to the allow\n list on the [**Authentication \\\u003e Settings**](//console.firebase.google.com/project/_/authentication/settings)\n page of the Firebase console.\n\nHandle the sign-in flow with the Firebase SDK\n\nTo handle the sign-in flow with the Firebase JavaScript SDK, follow these\nsteps:\n\n1. Create an instance of an `SAMLAuthProvider` using the provider ID you got in\n the Firebase console.\n\n Web \n\n import { SAMLAuthProvider } from \"firebase/auth\";\n\n const provider = new SAMLAuthProvider('saml.example-provider');\n\n Web \n\n var provider = new firebase.auth.SAMLAuthProvider('saml.example-provider');\n ``\n\n\u003c!-- --\u003e\n\n1. Authenticate with Firebase using the SAML provider object.\n\n You can either redirect the user to the provider's sign-in page or open the\n sign-in page in a pop-up browser window.\n\n **Redirect flow**\n\n Redirect to the provider sign-in page by calling `signInWithRedirect()`: \n\n Web \n\n import { getAuth, signInWithRedirect } from \"firebase/auth\";\n\n const auth = getAuth();\n signInWithRedirect(auth, provider);\n\n Web \n\n firebase.auth().signInWithRedirect(provider);\n\n After the user completes sign-in and returns to your app, you can obtain the\n sign-in result by calling `getRedirectResult()`. \n\n Web \n\n import { getAuth, getRedirectResult, SAMLAuthProvider } from \"firebase/auth\";\n\n const auth = getAuth();\n getRedirectResult(auth)\n .then((result) =\u003e {\n // User is signed in.\n\n // Provider data available using getAdditionalUserInfo()\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n Web \n\n firebase.auth().getRedirectResult()\n .then((result) =\u003e {\n // User is signed in.\n\n // Provider data available in result.additionalUserInfo.profile,\n // or from the user's ID token obtained from result.user.getIdToken()\n // as an object in the firebase.sign_in_attributes custom claim.\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n **Pop-up flow**\n\n Web \n\n import { getAuth, signInWithPopup, OAuthProvider } from \"firebase/auth\";\n\n const auth = getAuth();\n signInWithPopup(auth, provider)\n .then((result) =\u003e {\n // User is signed in.\n\n // Provider data available in result.additionalUserInfo.profile,\n // or from the user's ID token obtained from result.user.getIdToken()\n // as an object in the firebase.sign_in_attributes custom claim.\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n Web \n\n firebase.auth().signInWithPopup(provider)\n .then((result) =\u003e {\n // User is signed in.\n\n // Provider data available in result.additionalUserInfo.profile,\n // or from the user's ID token obtained from result.user.getIdToken()\n // as an object in the firebase.sign_in_attributes custom claim.\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n The ID token and [UserInfo](/docs/reference/js/auth.userinfo#userinfoemail)\n object contains the user's email address only if it is provided in the\n `NameID` attribute of the SAML assertion from the identity provider: \n\n \u003cSubject\u003e\n \u003cNameID Format=\"urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\"\u003etest@email.com\u003c/NameID\u003e\n \u003c/Subject\u003e\n\n2. While the above examples focus on sign-in flows, you can use the same\n pattern to link a SAML provider to an existing user using\n `linkWithRedirect()` and `linkWithPopup()`, and re-authenticate a user with\n `reauthenticateWithRedirect()` and `reauthenticateWithPopup()`, which can be\n used to retrieve fresh credentials for sensitive operations that require\n recent login."]]