Skip to content

qnipp/meteor-saml-demo

Repository files navigation

meteor-saml-demo

Demo for the qnipp:accounts-saml package

See the live demo on meteorapp.com.

Server configuration

Client configuration

The demo client is based on React.

  • The login is performed via a redirection. The respective links for all configured SAML providers are available through the saml.getLoginLinks method. See the example in import/ui/LoginLinks.jsx.
  • A successful login can easily detected using the reactive Meteor.user() method. See the example in import/ui/User.jsx.
  • An unsuccesful login can be detected by registering a callback to Accounts.onLoginFailure(). See the example in import/ui/LoginState.jsx.
  • If setting up the UI takes longer than the login, it might help to set Meteor.settings.public.saml.performPendingLoginManually to true and run performPendingLogin on a proper place.

See this example for the last point as part of the login form:

  const [loginState, setLoginState] = useState({ state: 'loggedout' });

  useEffect(() => {
    const onLoginFailure = Accounts.onLoginFailure((error) => {
      if (loginState.state === 'loggedout') {
        // to distinguish SAML logins from password logins
        setLoginState({ state: 'failure', error });
      }
    });
    performPendingLogin();
    return onLoginFailure.stop;
  }, []);

Further reading

See the README file of the package.