# Enterprise SSO Login & Signup

PropelAuth's Enterprise SSO Login & Signup component allows you to customize your login and signup pages by adding the ability to [login with SAML / Enterprise SSO](https://docs.propelauth.com/overview/authentication/saml). It is designed to be used when your user has a [Login State](https://ui.propelauth.com/login-signup-apis#login-state) of `LOGIN_REQUIRED`.

We highly recommend reviewing the [Login and Signup Guide](https://ui.propelauth.com/login-signup-apis) if using any of our login or signup components.

## SAML Login & Signup

Email

Login

## [Shadcn Installation](https://ui.propelauth.com/login-signup-apis/login-with-saml#shadcn-installation)

Install this component from our [shadcn registry](https://ui.propelauth.com/getting-started/component-registry).

```bash
npx shadcn@latest add https://components.propelauth.com/r/enterprise-sso-login.json
```

# Reference APIs

These are the APIs that are used by the above component. You can use these APIs directly in your own code.

## [loginViaSamlForOrg](https://ui.propelauth.com/login-signup-apis/login-with-saml#login-via-saml-for-org)

Accepts either a domain, email, or org_id and returns a Enterprise SSO login URL for the specified organization. Works with both OIDC and SAML login.

## Arguments

- Name `email`  Type string  Description The email of the user.
- Name `domain`  Type string  Description The domain of the user or organization, such as `acme.com`.
- Name `org_id`  Type string  Description The ID of the organization.

## Response Functions

The response object has a **handle** function that you can use to handle the response. These functions can be async, and you can return values from them.

- Name `success`  Description Successful request.
- Name `orgNotFound`  Description The provided org_id or domain is not tied to an existing org with SAML enabled.
- Name `unexpectedOrUnhandled`  Description An unexpected error occurred.

### Request

```javascript
const { loginViaSamlForOrg } = useAuthFrontendApis()

const response = await loginViaSamlForOrg({
    // only one of these is required
    email: "test@example.com",
    domain: "acme.com",
    org_id: "1189c444-8a2d-4c41-8b4b-ae43ce79a492"
})
response.handle({
    success(data) {
        // redirect to data.login_url
    },
    orgNotFound(error) {
        console.error('Org not found', error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled', error.user_facing_error)
    },
})
```

### Successful Response

```json
{
    "login_url": "https://example.com/saml/login"
}
```
