Skip to content

Commit

Permalink
Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
woodseowl committed Aug 16, 2024
1 parent 3ffe68d commit e810e21
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/CUAuth/DataObjects/ShibIdentity.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function __construct(
public readonly array $serverVars = [],
) {}

/**
* Shibboleth server variables will be retrieved from the request if not provided.
*/
public static function fromServerVars(?array $serverVars = null): self
{
if (empty($serverVars)) {
Expand All @@ -59,12 +62,18 @@ public function isWeillIdP(): bool
return str_contains($this->idp, 'med.cornell.edu');
}

/**
* Returns the primary email ([email protected]) if available, otherwise the alias email.
*/
public function email(): string
{
// eduPersonPrincipal name is [email protected], mail is alias email
return $this->serverVars['eduPersonPrincipalName'] ?? $this->mail;
}

/**
* Returns the display name if available, otherwise the common name.
*/
public function name(): string
{
return $this->serverVars['displayName'] ?? $this->serverVars['cn'] ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/CUAuth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ the `CUAuthenticated` event. This listener should take the `$userId` from the ev
log them in or create as user as needed.

> [AuthorizeUser](./Listeners/AuthorizeUser.php) is provided as a starting point for handling the CUAuthenticated event.
> It is simplistic and should be replaced with a site-specific implementation in the site code base.
> It is simplistic and should be replaced with a site-specific implementation in the site code base. It demonstrates retrieving user data from [ShibIdentity](./DataObjects/ShibIdentity.php) and creating a user if they do not exist.
If the REMOTE_USER server variable is not set or if the CUAuthenticated
event handling does not result in a user being logged in, the middleware will return an HTTP_FORBIDDEN response.
Expand Down

0 comments on commit e810e21

Please sign in to comment.