[FLOW3-general] Problem with authenticateAction
Markus Goldbeck
mgoldbeck at cross-content.com
Mon Oct 10 09:06:48 CEST 2011
Hi Andi,
thank you for your answer. I solved my problem with some hints from
Christopher Hlubek and an update from beta1 to beta2, but I forgot to
post my solution until now.
My main epic fail was that I relied on the Dokumentaion for beta2 and
used beta1. Their is a difference with the two Post Parameters for
authentification in the function "updateCredentials" which is to be
found at
TYPO3.FLOW3/Classes/Security/Authentifikation/Token/UsernamePassword.php.
So I used the false names in the Loginform. Also I had to add a "TYPO3"
before "FLOW3" in my Settings.yaml
This is the Loginform and Settings.yaml which worked out for me:
Settings.yaml
--
TYPO3:
FLOW3:
security:
authentication:
providers:
DefaultProvider:
providerClass: PersistedUsernamePasswordProvider
entryPoint:
WebRedirect:
uri: standard/authentication
authenticationStrategy: atLeastOneToken
Routes.yaml
-
name: 'Authentication'
uriPattern: 'authenticate'
defaults:
'@package': xyz.abc
'@controller': Standard
'@action': authenticate
Login Form
<f:form action="authenticate" method="post">
<table id="anmeldung">
<tr><td>
Benutzername:
</td>
<td>
<input type="text" id="username"
name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][UsernamePassword][username]"
value="" tabindex="1" />
</td>
</tr>
<tr>
<td>
Passwort:
</td>
<td>
<input type="password" id="password"
name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][UsernamePassword][password]"
value="" tabindex="2" />
</td>
</tr>
<tr>
<td><input type="submit" class="nav_button" id="anmelden"
value="Login" tabindex="3" /></td>
</tr>
</table>
</f:form>
Greets
Markus
Am 09.10.11 20:11, schrieb Andreas Förthner:
> Hi Markus,
>
> Seems like you were not authenticated. The fact that no
> AuthenticationRequiredException has been thrown is probably due to the
> default authentication strategy 'anyToken'. Try to change it to
> 'atLeastOneToken' in your Settings.yaml, then the exception will be
> thrown, if you could not get authenticated. We are currently discussing
> what will be the best default for this strategy and probably change it to
> 'atLeastOneToken'. Besides that everything looks good to me, however you
> could use the flow3 authentication controller. Then you won't have to
> implement it yourself and it has some nice features for redirecting to the
> original requests after authentication.
>
> Let me know if this helped.
>
> Greets Andi
>
> Am 29.09.11 09:37 schrieb "Markus Goldbeck" unter
> <mgoldbeck at cross-content.com>:
>
>> Hello everyone,
>>
>> I have got some problems with the authentication. I would like to have a
>> login in the Standard Controller, so you have to login to get any
>> further on the site. I used the "authenticateAction" and the settings
>>from the Blogexample.
>>
>> The routing is defined and the "authenticateAction" is called in the
>> StandardController. After sending the form with the right Login data I'm
>> landing on the redirected site with the error Message "Access denied!".
>> A CSRF-Token is generated.
>>
>> When I'm using a false Login I land on the same page. But here I would
>> expect the Exeption in the StandardController after a false Login.
>>
>> Furthermore I would expect that after Login with the right data as an
>> Admin and an redirect on the StandardController that I would get the
>> message form the ViewHelper "<f:security.ifHasRole role="Admin">"
>>
>> Can anybody give me some hint please where my problem is to solve.
>>
>> Best Regards
>>
>> Markus
>>
>> //Login Form
>> <f:security.ifHasRole role="PartnerMaster">
>> I am an Partner Master
>> </f:security.ifHasRole>
>> <f:security.ifHasRole role="Admin">
>> I am an Admin
>> </f:security.ifHasRole>
>> <div id="loginscreen">
>> <h1>Anmeldung</h1>
>> <p><f:flashMessages class="flashmessages" /></p>
>> <f:form action="authenticate" method="post">
>> Login:
>> <input type="text" id="username"
>>
>> name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][User
>> namePassword][username]"
>> value="" tabindex="1" />
>> Password:
>> <input type="password" id="password"
>>
>> name="__authentication[TYPO3][FLOW3][Security][Authentication][Token][User
>> namePassword][password]"
>> value="" tabindex="2" />
>> <input type="submit" value="Login" tabindex="3" />
>> </f:form>
>> </div>
>>
>> //StandardController
>> /**
>> * @inject
>> * @var \TYPO3\FLOW3\Security\Authentication\AuthenticationManagerInterface
>> */
>> protected $authenticationManager;
>>
>> public function authenticateAction() {
>> try {
>> $this->authenticationManager->authenticate();
>> $this->redirect('index', 'Projekt');
>> } catch
>> (\TYPO3\FLOW3\Security\Exception\AuthenticationRequiredException
>> $exception) {
>> $this->flashMessageContainer->add('Wrong username or
>> password.');
>> throw $exception;
>> }
>> }
>>
>>
>> //Policy.yaml
>> resources:
>> methods:
>> MBS_SUPortal_Projekt:
>> 'method(MBS\SUPortal\Controller\ProjektController->(index|new)Action())'
>> MBS_SUPortal_Angebot: 'class(MBS\SUPortal\Controller\Angebot\.*)'
>> MBS_SUPortal_Rechnung: 'class(MBS\SUPortal\Controller\Rechnung\.*)'
>> MBS_SUPortal_Restricted: 'class(MBS\SUPortal\Controller\User\.*)'
>> roles:
>> Admin: []
>> PartnerMaster: []
>> acls:
>> Admin:
>> methods:
>> MBS_SUPortal_Projekt: GRANT
>> MBS_SUPortal_Restricted: GRANT
>> MBS_SUPortal_Angebot: GRANT
>> MBS_SUPortal_Rechnung: GRANT
>> PartnerMaster:
>> methods:
>> MBS_SUPortal_Angebot: GRANT
>> MBS_SUPortal_Angebot: GRANT
>> MBS_SUPortal_Rechnung: GRANT
>>
>>
>> //Routes.yaml
>> -
>> name: 'Authentication'
>> uriPattern: 'authenticate'
>> defaults:
>> '@package': MBS.SUPortal
>> '@controller': Standard
>> '@action': authenticate
>>
>>
>> //Settings.yaml
>> --
>> FLOW3:
>> security:
>> authentication:
>> providers:
>> DefaultProvider:
>> providerClass: PersistedUsernamePasswordProvider
>>
> Andreas Förthner
> Leiter Web-Entwicklung
>
> Telefon: +49 (911) 539909 - 0
> E-Mail: andreas.foerthner at netlogix.de
> Website: media.netlogix.de
>
>
> --
> netlogix GmbH& Co. KG
> IT-Services | IT-Training | Media
> Andernacher Straße 53 | 90411 Nürnberg
> Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
> E-Mail: info at netlogix.de | Internet: http://www.netlogix.de
>
> netlogix GmbH& Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
> Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
> Umsatzsteuer-Identifikationsnummer: DE 233472254
> Geschäftsführer: Stefan Buchta, Matthias Schmidt
>
>
>
> _______________________________________________
>> FLOW3-general mailing list
>> FLOW3-general at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>
More information about the FLOW3-general
mailing list