Monolog Elasticsearch configuration in Symfony - symfony

I tried to configure Elasticsearch for monolog as mentioned here but the problem is that I don't find any way to pass my username and password for Elasticsearch since the ElasticsearchLogstashHandler service only takes an endpoint as input.
here's the service that I created:
elasticsearch_logstash_handler:
class: Symfony\Bridge\Monolog\Handler\ElasticsearchLogstashHandler
arguments: [ '%ELASTIC_SEARCH_ENDPOINT%']
I tried to put username and password in the URL (username:password#url) but since the password contains special characters it doesn't work this way.
thank you for sharing your ideas.

Related

How to use the # character as a password in WSO2 API Manager 4.0.0?

I am currently using the latest version of WSO2 APIM(4.0.0).
I tried connecting to the ldap as a readonly userstore as per the documentation, but once I startup the server a JMS error occurs possibly due to the # character used in the password.
Is it possible to use the # character without breaking WSO2 APIM functionality?
Thanks in advance.
It is not possible to use # in JMS connection string. Please check - https://apim.docs.wso2.com/en/latest/install-and-setup/setup/security/logins-and-passwords/maintaining-logins-and-passwords/#change-the-super-admin-credentials
The following worked for me.
In deployment.conf file configure the password with the special character as below.
[super_admin]
username = "your-name"
password = "<![CDATA[your-password]]>"
[apim.throttling.jms]
username = "your-name"
password = "<![CDATA[your-password]]>"
Thanks #Pubci for referring the relevant documentation link.

Symfony 5.3 Mailer setup env vars not reading correctly

In a Symfony 5.3 project I am using the Mailer (..\Symfony\Component\Mailer\MailerInterface) to send mails.
For devolopment I required "symfony/google-mailer" with composer and set it up in .env.local.
Say username is "example#gmail.com" and password is "0000".
In .env.local I specified
MAILER_USER='example#gmail.com'
MAILER_PASSWORD='0000'
MAILER_DSN=gmail://MAILER_USER:MAILER_PASSWORD#default
which results in error
Failed to authenticate on SMTP server with username "MAILER_USER" using the following authenticators: "LOGIN", "PLAIN", "XOAUTH2". Authenticator "LOGIN" returned "Symfony\Component\Mailer\Exception\TransportException: Expected response code "235" but got code "535", with message "535-5.7.8 Username and Password not accepted.
As stated in the docs I changed the one special character in user name ("#") to it's URL-encoded form like
MAILER_USER='example%40gmail.com'
which then results in the error
Email "example%40gmail.com" does not comply with addr-spec of RFC 2822.
(Obviously the URL-encoding didn't work like expected (because it wasn't reversed?))
I tried to load the env vars in paramaters in services.yaml and use the parameters instead - but that lead to the first error too.
If I write the auth infos into the MAILER_DSN env var directly it just works fine without problems, like
MAILER_DSN=gmail://example#gmail.com:0000#default
So this seems to be a syntax problem which I can't figure out from the docs.
Any hints?
You should remove the single quotes and you need to wrap the env variables used in other env variables with ${} sic
MAILER_USER=example#gmail.com
MAILER_PASSWORD=0000
MAILER_DSN=gmail://${MAILER_USER}:${MAILER_PASSWORD}#default
Result:
$_SERVER['MAILER_DSN'] = "gmail://example#gmail.com:0000#default"
.env :
MAILER_DSN=smtp://username:password#smtp.gmail.com
You have to enable access to applications in google parameters (security).

Configure MongoDB 3 user roles in SaltStack SLS

Is there a way to configure user roles with SaltStack for MongoDB 3? I see that the mongodb module has relevant role management functions, but the mongodb_user state does not refer to roles anywhere.
Yes, there certainly is!
You'll want to use the Mongodb module, and execute it from a state using module.run.
so, for example, if you want to manage the roles of a user 'TestUser', you'd create 'manage_mongo_roles.sls', and it will contain states like the following:
manage_mongo_roles:
module.run:
- name: mongodb.user_grant_roles
- m_name: TestUser
- roles: ["admin"]
- database: admin
- user: admin
- password: ''
- host: localhost
- port: 27017
The 'name' paramater for the module MUST be prefaced with a m_, so that the state knows to pass this to the module and not use it as the name of the module to be executed.
Also note that the role MUST be of the format
["role"]
The documentation indicates that, if run from the salt CLI it should be contained in single quotes, like so:
'["role"]'
but doing so in the module.run state WILL cause it to fail, and return with a less than descriptive error message.

HWIOAuthBundle Symfony2 facebook login route name

Where do I find the route name for logging in with facebook? I don't want to hardcode the routes into the twig templates.
Short answer
Route name is hwi_oauth_service_redirect:
Name Method Scheme Host Path
hwi_oauth_service_redirect ANY ANY ANY /connect/{service}
So, for facebook you can generate connect route in view via:
{{ path('hwi_oauth_service_redirect', { service: 'facebook' }) }}
How to debug similar problems
I was also amazed how HWIOAuthBundle doesn't mention route name in documentation anywhere, or at least it isn't obviously stated and I couldn't find it.
When you have this kind of problem, you can use $ app/console router:debug command, which will provide you dump of all routes defined.

No Scopes Specified - Google_Auth_Exception

I am applying this tutorial into symfony 2.4, I've finished the setup in the config.yml and everything, I managed to visit the admin/google/analytics page, but the problem is when I tried to authenticate with the parameters I've created in the config.yml file, it is searching for the scope, here is the parameters.
happy_r_google_analytics:
host: www.example.com
profile_id: MyProfileId
tracker_id: UA-TRACKER-ID
token_file_path: %kernel.root_dir%/var/storage
happy_r_google_api:
application_name: Project Default Service Account
oauth2_client_id: OAuthClientID
oauth2_client_secret: OAuthClientSecret
oauth2_redirect_uri: http://www.example.com/app_local.php/admin/google/analytics/oauth2callback
developer_key: DevelopperKey
site_name: http://www.example.com
I think there's no problem here, I've got no idea where I can set the scope so the google Api client can set it to https://www.googleapis.com/auth/analytics.readonly
You need to define a scope. If you use Google Auth, check Authorization scopes for it.
You must do something like:
$googleClient = new \Google_Client();
$googleClient->setScopes(array(
'https://www.googleapis.com/auth/plus.me',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
));

Resources