How to translate SecurityContext:AUTHENTICATION_ERROR? - symfony

I'm using FosUserBundle with Symfony2.1 and when I try to connect a user that is not enabled, the following error is displayed on my form : User account is disabled, which is great but it is a French website and I would like to translate this message in french.
I've already translated session messages and validators in translations folder : messages.fr.yml and validators.fr.yml and MyUserBundle.fr.yml but I can't get the ones created by the SecurityContext.

All messages from FOSUserBundle are using "FOSUserBundle" as the message domain. So you have to put your translation into ./app/Resources/translations/FOSUserBundle.fr.yml.
If you've derived your own bundle based on FOSUserBundle the file goes into ./src/YourUserBundle/Resources/translations/FOSUserBundle.fr.yml.

Related

Get username in magnolia

I am using the following command to get the username in a custom magnolia class:String userName = MgnlContext.getInstance().getJCRSession("website").getUserID();
Instead of getting the name of the user who is signed on in magnolia when the command was triggered I am getting admin for the value. How can I get the real user name - the one who signed on to magnolia?
Actually to get current user, what you want is to either inject MgnlContext or get it via MgnlContext.getInstance() call.
Once you have context, you call ctx.getUser().getName() to get current user name.
You can inject info.magnolia.cms.security.SecuritySupport to your class and use
info.magnolia.cms.security.SecuritySupport#getUserManager()
afterwards, you are exposed to plenty of utility method that one can fetch all users or users by group etc.

Presto custom PasswordAuthenticator plugin for coordinator authentication is not triggered

I created a presto custom password authenticator plugin (internal) by making a copy of the LDAP plugin and modifying it. You can see that code here: https://github.com/prestodb/presto/tree/master/presto-password-authenticators/src/main/java/com/facebook/presto/password.
I created copies of the Authenticator, AuthenticatorFactory, and the config, and modified them to basically just take a user/password from the config and to only allow that user in. I also put the new class in the PasswordAuthenticatorPlugin registration code.
I can see the plugin loading when presto is started, but it doesn't appear to do anything despite no errors being present. What am I missing?
Note: I had already found a solution to this, I'm just recording it on SO as I originally came here and found no help.
To make a custom password plugin work, you actually need HTTPS enabled for communication with the coordinator. You can actually see this recommendation at the bottom of their documentation:
https://prestodb.github.io/docs/current/develop/password-authenticator.html
Additionally, the coordinator must be configured to use password authentication and have HTTPS enabled.
So, the steps to make it work are:
Make sure your main config.properties has "http-server.authentication.type=PASSWORD".
Make sure you add a password-authenticator.properties next to config properties with content like the sample in the link above. But make sure you use your string from your authenticator as the name, and that you add your configuration properties instead (user name and password).
Set up a JKS store or a real certificate (some instructions here from Presto for JKS: https://prestodb.github.io/docs/current/security/tls.html).
Add SSL config to your config.properties.
http-server.https.enabled=true
http-server.https.port=8443
http-server.https.keystore.path=/etc/presto-keystore/keystore.jks
http-server.https.keystore.key=password123
Set up your JDBC driver to use the same key store.
I wrote up a blog on it with a bit more detail as well if any of that doesn't make sense. But after doing all this, you should find that it does require a password and it does enforce your plugin.
https://coding-stream-of-consciousness.com/2019/06/18/presto-custom-password-authentication-plugin-internal/

FOSUserBundle missing parameter token for password reset issue

I have a Symfony 3 CRM, but there seems to be an issue with the password resetting (for which I am using FOS User Bundle). A user can enter their email, they get the email with a link, but when they reach the page to change their password, the following error is logged:
An exception has been thrown during the rendering of a template ("Some
mandatory parameters are missing ("token") to generate a URL for route
"fos_user_resetting_reset".") in FOSUserBundle::layout.html.twig at
line 54.
So, I checked the route in the FOSUserBundle config (bearing in mind, I have not altered this file or anything within the friendsofsymfony directory):
<route id="fos_user_resetting_reset" path="/reset/{token}" methods="GET POST">
<default key="_controller">FOSUserBundle:Resetting:reset</default>
</route>
And the URL being visited:
https://crm.mysite.co.uk/resetting/reset/sAt7xPNzW4AempvzK6m2xRRN7jI058xAQjbct7GgyqI
which as you can see clearly passes a token. I've had strange issues like this before, if for example I don't pass a default value in my route (even if there's clearly a token or some other required parameter passed) but since this is a separate bundle and is in XML rather than YML I don't know how to fix this. I'm not entirely sure why it's even throwing an error?
Any help with this appreciated.
try to view inside your console the route inside your app by doing:
bin/console debug:route
In this list you can get all available url
A possibility is that you need to call only:
https://crm.mysite.co.uk/reset/sAt7xPNzW4AempvzK6m2xRRN7jI058xAQjbct7GgyqI

Wordpress: Contact Form 7 Plugin Error: This email address does not belong to the same domain as the site

My wordpress installation was working fine all this time, until it upgraded contact form 7 to Version 4.4 now it has a configuration error.
"Contact Form 7 Plugin Error: This email address does not belong to the same domain as the site"
Try this, because it worked for me:
From: [first-name] [last-name] <donotreply#your-site.com>
Of course your-site.com is your domain and you might not have first and last names.
It's said that you to create a #mysite.com email with your host, maybe something like do-not-reply#mysite.com.
Hope that helps,
Change the current “your-email” to admin#yourdomain.com OR the email address that you receive messages from. It is also possible to create a new email address specifically for this purpose, you could name it “no-reply#yoursite.com”. You can drill-down more here.
Contact Form 7 Issues

Integrate twitter in drupal 7 website

I am trying to get the twitter module (7.x-5.4) running on my local drupal 7.19 website. Already installed Oauth and registered a twitter app. I am using the keys of that twitter app.
Callback URL
http://localhost/drupal-7.19/twitter/oauth
twitter host
http://twitter.com
Twitter API
https://api.twitter.com
Twitter search
http://search.twitter.com
TinyURL
http://tinyurl.com
when I want to add at least my own twitter account so that the site can display my tweets. when I want to add this account, an error occurs:
Notice: Undefined property: stdClass::$data in Twitter->request() (line 131 of root\modules\twitter\twitter.lib.php).
Could not obtain a valid token from the Twitter API. Please review the configuration.
any ideas? thanks in advance.
In my case, uncommenting the line
extension=php_openssl.dll
in php.ini resolved the error.
I'm not sure this will work for you, but this worked for me. I had the same exact error, even though I had followed the documentation. Here's the test: go to admin/reports/status. If you see the following warning: "HTTP request status Fails" this means your drupal/LAMP stack is unable to use DNS to callback to itself. In my case I used my machines's IP to access my Drupal instance. So, rather that use "localhost" use your machine's IP address (you can use ipconfig on MSWin or ifconfig on Mac/Linux) and use that for finishing the twitter account setup process.
Again, not
http://localhost/drupal-7.19/twitter/oauth
but
http://10.0.1.9/drupal-7.19/twitter/oauth
(substituting your machine's IP address)
I was getting the exact same error which i fixed by adding appropriate proxy server details.
Notice: Undefined property: stdClass::$data in Twitter->request() (line 131 of C:\wamp\www\test_twitter\sites\all\modules\twitter\twitter.lib.php
The problem was due to proxy-settings. I added values for $conf['proxy_server'] and $conf['proxy_port'] in settings.php and this error vanished.
I also verified that if i remove the proxy settings, this error is reproduced again.
Install oauth_common and twitter on your Drupal site
Check that both Oauth and the Twitter modules are enabled. I didn't use any of the other Twitter modules to do this
Go to the twitter module in Drupal
Go to the Configure (button) -> settings (Tab)
(note that the Callback URL is http://localhost/yourwebsite/twitter/oauth i.e. it doesn’t have to be 127.0.0.1)
Click on the link that says register your application
Go to twitter and sign in to be a developer
Add a new application, making a distinct feed name
Enter your site details
For localhost use: http://127.0.0.1:8000/twitter/oauth for both the website and callback URLs
Press save when you've done
Next go to the Test OAuth button - this will give you your illusive consumer key and consumer secret key
Back to the Drupal website and and to the twitter module to configure (button) -> settings (Tab)
Copy and paste these consumer and consumer secret keys you just got
Press Save configuration
Hopefully no errors.
Go to the twitter tab in the module and hopefully your twitter avatar has appeared
Read the top of the page where it says "Tweets are pulled from Twitter by running cron. You can view the full list of tweets at the Tweets view."
Select the View Tweets checkbox and click view - Chances are your tweets won’t show up in the next window - yet
Go to your drupal Configuration screen and to [System] Cron and press the "Run cron"
Now go back to view tweets from the twitter module and they should all appear
[This was a pig to figure out]

Resources