Skip to content

Commit

Permalink
Add handling of multiple fields for oc displayName (eg. firstnames+la…
Browse files Browse the repository at this point in the history
…stnames), remove type hints to use with php 5.6 version
  • Loading branch information
felixrupp committed Jun 19, 2018
1 parent db6902a commit 702cd65
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 43 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG
=========

Version 1.5.1
-------------
* Hotfixes wrong links in 403 error page if enforce authentication was on
* Hotfixes wrong translation in 403 error page for ECAS instances
* Removes return type hints not compatible with PHP 5.6
* Adds functionality to provide more than one mapping field to ownCloud userdata fields (e.g. DisplayName can now be concatenated by a firstname and a lastname CAS-field)

Version 1.5.0
-------------
* Drop ownCloud 9 support
Expand Down
11 changes: 3 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
## Submitting issues

If you have questions about how to install or use ownCloud, please direct these to the [mailing list][mailinglist] or our [forum][forum]. We are also available on [IRC][irc].

### Short version

* The [**issue template can be found here**][template]. Please always use the issue template when reporting issues.
If you have questions about how to install or use ownCloud, please direct these to the [mailing list][mailinglist], the [forum][forum] or the [IRC Chat][irc].

### Guidelines
* Please search the existing issues first, it's likely that your issue was already reported or even fixed.
Expand All @@ -13,13 +9,12 @@ If you have questions about how to install or use ownCloud, please direct these
- More info on [search syntax within github](https://help.github.com/articles/searching-issues)
* This repository ([user_cas](https://github.com/felixrupp/user_cas/issues)) is *only* for issues within the ownCloud user_cas code.
* __SECURITY__: Report any potential security bug to [email protected] following our [security policy](https://owncloud.org/security/) instead of filing an issue in our bug tracker
* Report the issue using our [template][template], it includes all the information we need to track down the issue.
* Report the issue using our template, it includes all the information we need to track down the issue.

Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues.

[template]: https://raw.github.com/owncloud/core/master/issue_template.md
[mailinglist]: https://mailman.owncloud.org/mailman/listinfo/owncloud
[forum]: https://forum.owncloud.org/
[forum]: https://central.owncloud.org
[irc]: https://webchat.freenode.net/?channels=owncloud&uio=d4

### Contribute Code and translations
Expand Down
28 changes: 8 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
INTRODUCTION
============

This App provides CAS authentication support, using the phpcas library of jasig/apereo.
This App provides CAS authentication support, using the phpCAS library of jasig/apereo.

INSTALLATION
============

DEPENDENCIES
-------------------

* ownCloud 10.0.0 or higher
* ownCloud 10.0.0 to 10.0.7 and Nextcloud 13.0.0 to 13.0.3
* PHP >= 5.6, PHP 7.0 or 7.1 if possible
* [Composer Dependency Manager](https://getcomposer.org/), if you want to install via GIT.
* Optional: [Composer Dependency Manager](https://getcomposer.org/), if you want to install via GIT.

This app does not require a standalone version of jasig’s/apereo’s phpcas any longer. The library is shipped within composer dependencies or in the archive file you downloaded. Although you can configure to use your own version of jasig’s/apereo’s phpcas library later on.
This app does not require a standalone version of jasig’s/apereo’s phpCAS any longer. The library is shipped within composer dependencies, in the archive file you downloaded or the Market/App-Store version if used. Although you can configure to use your own version of jasig’s/apereo’s phpCAS library later on.


STEPS
GIT: STEPS
-----

1. Git clone/copy the downloaded `user_cas` folder into the ownCloud's apps folder and make sure to set correct permissions for your Webserver.
2. Change directory inside `user_cas` folder after cloning and perform a `composer update` command if you installed via GIT. The dependencies will be installed. Attention: You will need the [composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) binary to be installed.
3. Adjust the settings for the `user_cas` folder according to your webserver setup.
4. Access the ownCloud web interface with a locally created ownCloud user with admin privileges.
5. Access the administrations panel => Apps and enable the **CAS user and group backend** app.
6. Access the administration panel => Authentication and configure the app.
6. Access the administration panel => Authentication (Additional on Nextcloud) and configure the app.


CONFIGURATION
Expand Down Expand Up @@ -72,7 +72,7 @@ If CAS provides extra attributes, `user_cas` can retrieve the values of them. Si

**Email**: Name of email attribute in CAS. Default: empty

**Display Name**: Name of display name attribute in CAS (this might be the "real name" of a user). Default: empty
**Display Name**: Name of display name attribute(s) in CAS (this might be the "real name" of a user or a combination of two fields like: firstnames+surnames). Default: empty

**Group**: Name of group attribute in CAS. Default: empty

Expand All @@ -92,7 +92,7 @@ Groups
ECAS Settings:
--------------

user_cas since Version 1.5 provides support for using a European Commission ECAS-Server implementation.
Since Version 1.5 user_cas provides support for using a European Commission ECAS-Server implementation.

**Use ECAS Attribute Parser?**: Activate the ECAS attribute parser to enable the parsing of groups provided by the European Commission ECAS implementation (do NOT activate until you know what you are doing).

Expand Down Expand Up @@ -138,18 +138,6 @@ Bugs and Support
==============

Please contribute bug reports and feedback to [GitHub Issues](https://github.com/felixrupp/user_cas/issues).
If you are observing undesired behaviour, think it is a bug and want to tell me about, please include following parts:
* What led up to the situation?
* What exactly did you do (or not do) that was effective (or ineffective)?
* What was the outcome of this action?
* What outcome did you expect instead?

Also please provide basic information of your ownCloud instance:
* ownCloud Version
* PHP Version
* CAS Version
* phpCAS library version
* The part of the owncloud.log file, from -5min. before and +5min. after the bug happened

ABOUT
=====
Expand Down
22 changes: 19 additions & 3 deletions lib/Hooks/UserHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,31 @@ public function postLogin(\OCP\IUser $user, $password)
$attributes = array();
$this->loggingService->write(\OCP\Util::DEBUG, 'Attributes for the user: ' . $uid . ' => ' . $casAttributesString);


// DisplayName
$displayNameMapping = $this->config->getAppValue($this->appName, 'cas_displayName_mapping');
if (array_key_exists($displayNameMapping, $casAttributes)) {

$attributes['cas_name'] = $casAttributes[$displayNameMapping];
} else if (array_key_exists('displayName', $casAttributes)) {
$displayNameMappingArray = explode("+", $displayNameMapping);

$attributes['cas_name'] = '';

foreach($displayNameMappingArray as $displayNameMapping) {

if (array_key_exists($displayNameMapping, $casAttributes)) {

$attributes['cas_name'] .= $casAttributes[$displayNameMapping]." ";
}
}

$attributes['cas_name'] = trim($attributes['cas_name']);

if ($attributes['cas_name'] === '' && array_key_exists('displayName', $casAttributes)) {

$attributes['cas_name'] = $casAttributes['displayName'];
}


// E-Mail
$mailMapping = $this->config->getAppValue($this->appName, 'cas_email_mapping');
if (array_key_exists($mailMapping, $casAttributes)) {

Expand Down
24 changes: 12 additions & 12 deletions lib/Service/AppService.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,95 +707,95 @@ public function setCasServiceUrl($casServiceUrl)
/**
* @return bool
*/
public function isCasDisableLogout(): bool
public function isCasDisableLogout()
{
return $this->casDisableLogout;
}

/**
* @param bool $casDisableLogout
*/
public function setCasDisableLogout(bool $casDisableLogout)
public function setCasDisableLogout($casDisableLogout)
{
$this->casDisableLogout = $casDisableLogout;
}

/**
* @return string
*/
public function getCasEcasAcceptedStrengths(): string
public function getCasEcasAcceptedStrengths()
{
return $this->cas_ecas_accepted_strengths;
}

/**
* @param string $cas_ecas_accepted_strengths
*/
public function setCasEcasAcceptedStrengths(string $cas_ecas_accepted_strengths)
public function setCasEcasAcceptedStrengths($cas_ecas_accepted_strengths)
{
$this->cas_ecas_accepted_strengths = $cas_ecas_accepted_strengths;
}

/**
* @return string
*/
public function getCasEcasRetrieveGroups(): string
public function getCasEcasRetrieveGroups()
{
return $this->cas_ecas_retrieve_groups;
}

/**
* @param string $cas_ecas_retrieve_groups
*/
public function setCasEcasRetrieveGroups(string $cas_ecas_retrieve_groups)
public function setCasEcasRetrieveGroups($cas_ecas_retrieve_groups)
{
$this->cas_ecas_retrieve_groups = $cas_ecas_retrieve_groups;
}

/**
* @return string
*/
public function getCasEcasAssuranceLevel(): string
public function getCasEcasAssuranceLevel()
{
return $this->cas_ecas_assurance_level;
}

/**
* @param string $cas_ecas_assurance_level
*/
public function setCasEcasAssuranceLevel(string $cas_ecas_assurance_level)
public function setCasEcasAssuranceLevel($cas_ecas_assurance_level)
{
$this->cas_ecas_assurance_level = $cas_ecas_assurance_level;
}

/**
* @return bool
*/
public function isEcasAttributeParserEnabled(): bool
public function isEcasAttributeParserEnabled()
{
return $this->ecasAttributeParserEnabled;
}

/**
* @param bool $ecasAttributeParserEnabled
*/
public function setEcasAttributeParserEnabled(bool $ecasAttributeParserEnabled)
public function setEcasAttributeParserEnabled($ecasAttributeParserEnabled)
{
$this->ecasAttributeParserEnabled = $ecasAttributeParserEnabled;
}

/**
* @return bool
*/
public function isCasEcasRequestFullUserdetails(): bool
public function isCasEcasRequestFullUserdetails()
{
return $this->cas_ecas_request_full_userdetails;
}

/**
* @param bool $cas_ecas_request_full_userdetails
*/
public function setCasEcasRequestFullUserdetails(bool $cas_ecas_request_full_userdetails)
public function setCasEcasRequestFullUserdetails($cas_ecas_request_full_userdetails)
{
$this->cas_ecas_request_full_userdetails = $cas_ecas_request_full_userdetails;
}
Expand Down

0 comments on commit 702cd65

Please sign in to comment.