Skip to content

Commit 05a6597

Browse files
awolfdenAdam Wolfmanedignot
authored
Update UI/UX for PHP SSO app (#28)
* Update UI/UX for PHP SSO app * remove connection id suggestions --------- Co-authored-by: Adam Wolfman <[email protected]> Co-authored-by: Edita Ignot <[email protected]>
1 parent 7f115c5 commit 05a6597

File tree

8 files changed

+370
-194
lines changed

8 files changed

+370
-194
lines changed

php-sso-example/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ Composer - [Link](https://getcomposer.org/)
1818

1919
2. Follow the instructions [here](https://docs.workos.com/sso/auth-flow) on setting up an SSO connection. The redirect URL for the example app if used as is will be http://localhost:8000/auth/callback.
2020

21-
3. Edit lines 14 of `router.php` to declare the connectionID.
22-
23-
4. Create a new file called `.env` and enter your API Key, Client ID, and Organization ID from the WorkOS Dashboard.
21+
3. Create a new file called `.env` and enter your API Key, Client ID, and Organization ID from the WorkOS Dashboard.
2422

2523
```
2624
WORKOS_API_KEY="your_api_key"

php-sso-example/router.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,34 @@ function httpNotFound()
5353

5454
/* There are 6 parameters for the GetAuthorizationURL Function
5555
Domain (deprecated), Redirect URI, State, Provider, Connection and Organization
56-
These can be read about here: https://workos.com/docs/reference/sso/authorize/get
57-
We recommend using Connection (pass a connectionID) */
56+
These can be read about here: https://workos.com/docs/reference/sso/authorize/get */
5857

5958
case ("/auth"):
60-
$authorizationUrl = (new \WorkOS\SSO())
59+
60+
$loginType = $_POST['login_method'];
61+
62+
63+
64+
// Set the organization or provider based on the login type
65+
if ($loginType == "saml") {
66+
$authorizationUrl = (new \WorkOS\SSO())
6167
->getAuthorizationUrl(
6268
null, //domain is deprecated, use organization instead
6369
'http://localhost:8000/callback', //redirectURI
6470
[], //state array, also empty
6571
null, //Provider which can remain null unless being used
66-
null, //Organization which is the WorkOS Organization ID,
67-
$WORKOS_ORGANIZATION_ID //organization ID, to identify connection based on organization ID
68-
);
72+
null, //Connection which is the WorkOS Organization ID,
73+
$WORKOS_ORGANIZATION_ID //organization ID, to identify connection based on organization ID,
74+
);
75+
} else {
76+
$authorizationUrl = (new \WorkOS\SSO())
77+
->getAuthorizationUrl(
78+
null, //domain is deprecated, use organization instead
79+
'http://localhost:8000/callback', //redirectURI
80+
null, //state array, also empty
81+
$loginType, //Provider which can remain null unless being used
82+
);
83+
}
6984

7085
header('Location: ' . $authorizationUrl, true, 302);
7186
return true;

0 commit comments

Comments
 (0)