Code Monkey home page Code Monkey logo

ldap's Introduction

Neos Ldap Documentation

Example LoginController

LoginController.php:

<?php
namespace My\Package\Controller;

use Neos\Flow\Annotations as Flow;
use Neos\Flow\Security\Authentication\Controller\AbstractAuthenticationController;

/**
 * @Flow\Scope("singleton")
 */
class LoginController extends AbstractAuthenticationController {

        /**
         * Default action, displays the login screen
         *
         * @param string $username Optional: A username to prefill into the username field
         * @return void
         */
        public function indexAction($username = NULL) {
                $this->view->assign('username', $username);
        }

        /**
         * @param \Neos\Flow\Mvc\ActionRequest $originalRequest
         * @return string|void
         */
        public function onAuthenticationSuccess(\Neos\Flow\Mvc\ActionRequest $originalRequest = NULL) {
                $this->redirect('status');
        }

        /**
         * Logs out a - possibly - currently logged in account.
         *
         * @return void
         */
        public function logoutAction() {
                $this->authenticationManager->logout();
                $this->addFlashMessage('Successfully logged out.');
                $this->redirect('index');
        }

        /**
         * @return void
         */
        public function statusAction() {
                $this->view->assign('activeTokens', $this->securityContext->getAuthenticationTokens());
        }

}

Index.html:

<f:form action="authenticate" >
        <f:flashMessages class="errorMessages" />
                <div>
                        <label>User</label>
                        <input type="text" name="__authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][username]" id="username" value="{username}" />
                </div>
                <div>
                        <label>Password</label>
                        <input type="password" name="__authentication[Neos][Flow][Security][Authentication][Token][UsernamePassword][password]" id="password" />
                </div>
                <f:form.submit value="Login" />
        </div>
</f:form>

Status.html:

Status: Logged in<br/>
User: {activeTokens.LdapProvider.account.accountIdentifier}<br/>
<f:link.action action="logout">Logout</f:link.action>

Make sure you configure the policies so that the login and logout actions are available for the user. For that use a Policy.yaml like:

resources:
  methods:
        My_Package_LoginController: 'method(My\Package\Controller\LoginController->(index|status|login|authenticate|logout)Action())'

  acls:
    Everybody:
      methods:
        My_Package_LoginController: GRANT

Configuration examples

You can find examples of a Settings.yaml file for Ldap and Active Directory in the Configuration/ folder of the Neos.Ldap package.

ldap's People

Contributors

albe avatar comir avatar davidspiola avatar fschwaiger avatar guangha avatar jonnitto avatar julianwachholz avatar kdambekalns avatar mrimann avatar rafaelka avatar sebobo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ldap's Issues

Flow 5.x compatibility

The current dev-master is requiring Flow 4.x and thus the package cannot easily be installed in a Flow 5.x based application scenario.

DN should be escaped in DirectoryService::getMemberOf

Problem: If an DN had some escaped special Characters in the value (at my scenario it is a comma), then getMemberOf Method crashed with "wrong Credentials".

Added this Method (copied from moodle-code).
/** * Quote control characters in texts used in LDAP filters - see RFC 4515/2254 * * @param string filter string to quote * @return string the filter string quoted */ protected function ldap_filter_addslashes($text) { $text = str_replace('\\', '\\5c', $text); $text = str_replace(array('*', '(', ')', "\0"), array('\\2a', '\\28', '\\29', '\\00'), $text); return $text; }

Only variables should be passed by reference

Neos_Ldap_Service_BindProvider_ActiveDirectoryBind.php, line 58

Please change...

array_pop(explode('\\', $username))

...to...

$usernameSegments = explode('\\', $username);
array_pop($usernameSegments);

Write to error log if a group or user mapping is defined but mapping failed

In one of my projects the customer changed something in their LDAP and the users
couldn't get mapped anymore which led to the login form just to reload and not log in without
any helpful logging. The basic authentication works out but the user cannot do anything.

I would add some error logging to the LdapProvider in case this happens so at least this way it's possible to find the issue faster.

Remove standin authentication feature

The standin authentication allows for caching of the credentials on a local instance so the accounts can still be verified if the server is offline. This seemed like a good idea but it imposes a security risk where accounts could authenticate with old credentials if the connection to the server is disrupted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.