spinnaker rbac with ldap: can't get correct role by email UserDnAttribute - rbac

Is that possible to login with the email address and then get the correct roles provided by ldap of the email login ? If the answer is Yes, how to configure it? Please help me, thank you guys!!!

Cloud Provider(s):
k8s v2
Environment:
spinnaker 1.19.2
Feature Area:
helm3 install

halyard config:
authn:
ldap:
enabled: true
url: ldap://URL:port
userSearchBase: dc=test,dc=com
userDnPattern: mail={0},ou=Users
userSearchFilter: (&(mail={0})(employeeType=1)(|(memberOf=cn=admins,ou=Groups,dc=test,dc=com)(memberOf=cn=devs,ou=Groups,dc=test,dc=com)(memberOf=cn=tests,ou=Groups,dc=test,dc=com)))
managerDn: cn=manager,dc=test,dc=com
managerPassword: password
authz:
groupMembership:
service: LDAP
ldap:
roleProviderType: LDAP
url: ldap://URL:port/dc=test,dc=com
managerDn: cn=manager,dc=test,dc=com
managerPassword: password
userSearchBase: dc=test,dc=com
userDnPattern: cn={0},ou=Users
groupSearchBase: ou=Groups
groupSearchFilter: (uniqueMember={0})
groupRoleAttributes: cn
enabled: true

Related

Symfony 6: Check DB Entity when LDAP login fails or succeeds

I'm banging my head on the keyboard for a while now trying to solve something that should be simple but for some reason it has not been.
Here is the scenario. A user will use a form on my website to login (username/pwd). And the following workflow should work:
Try to authenticate the user on the LDAP server:
1.1. If it passes:
1.1.1. Check if there is an user with the same username on our database;
1.1.1.1. If it has, load some data and log in the user;
1.1.1.2. If it has not, throws a failed login.
1.2. If it fails:
1.2.1. Check if there is an user with the same username on our database;
1.2.1.1. If it exists
1.2.1.1.1 Check if the pwd match the save one, if it matches, log the user
1.2.1.2. If it has not, throws a failed login.
So basically, I'm trying to authenticate the user on the LDAP server, and if that fails, I want to try to authenticate locally.
I tried configuring multiple User Providers, using a chain provider, but it does not work. If the first UserProvider fails, it never hits the second one.
# config/security.yaml
security:
providers:
# base local provider
app_user_provider:
entity:
class: App\Entity\User\User
property: username
# LDAP provider
my_ldap:
ldap:
service: Symfony\Component\Ldap\Ldap
base_dn: '%env(resolve:LDAP_BASEDN)%'
search_dn: '%env(resolve:LDAP_SEARCHDN)%'
search_password: '%env(resolve:LDAP_SEARCHPWD)%'
default_roles: ROLE_USER
extra_fields: '%env(resolve:LDAP_EXTRAFIELDS)%'
uid_key: uid
filter: null
# chain
all_users:
chain:
providers: ['my_ldap', 'app_user_provider']
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
lazy: true
provider: all_users
form_login_ldap:
enable_csrf: true
default_target_path: app_homepage
login_path: app_login
check_path: app_login
service: Symfony\Component\Ldap\Ldap
username_parameter: username
password_parameter: password
dn_string: '%env(resolve:LDAP_BASEDN)%'
query_string: '%env(resolve:LDAP_QUERYSTR)%'
search_dn: '%env(resolve:LDAP_SEARCHDN)%'
search_password: '%env(resolve:LDAP_SEARCHPWD)%'
What am I missing? I found a couple of answers here (like Symfony 5: ldap authentication with custom user entity) but it uses the old Authenticator Guard that does not exists.

Sending Email in Symfony 3 in dev mode

In need help learning how to send email in development mode using the Symfony framework with the Swift_mailer library.
Here is my config_dev.yml file:
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
And my config.yml file:
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
spool: { type: memory }
And my parameters.yml file:
....
mailer_transport: gmail
mailer_host: 127.0.0.1
mailer_user: 'my_gamil_here'
mailer_password: 'my_password_here'
Then in my controller I have the following:
public function indexAction(\Swift_Mailer $mailer)
{
$message = (new \Swift_Message('Hello Email'))
->setFrom('westtexascentral555#gmail.com')
->setTo('kaleyaw#yahoo.com')
->setBody(
$this->renderView(
// app/Resources/views/Emails/registration.html.twig
'Emails/registration.html.twig',
array('name' => 'James')
),
'text/html'
);
$mailer->send($message);
return new Response('Email sent');
}
Can Someone tell me what I'm going wrong. Nothing gets sent to the email account.
Maybe it's because you specified mailer host as localhost. Check this symfony docs http://symfony.com/doc/current/email/gmail.html. And pay attention to this part:
The gmail transport is simply a shortcut that uses the smtp transport
and sets these options:
encryption ssl
auth_mode login
host smtp.gmail.com
Make sure, that mailer_user is set only to your gmail username (without host part). Let's say if I have email myemail#gmail.com, my username would be myemail.
Are you using 2-step verification for your gmail account? If so, additionally you need to generate app password for your account, as specified in docs:
If your Gmail account uses 2-Step-Verification, you must generate an App password and use it as the value of the mailer_password parameter. You must also ensure that you allow less secure apps to access your Gmail account.
Shortly, you can follow here, login, select app (in this case Mail) and the device you want to use mailer with, press Generate and you will see modal with your app password, similar to this snub udpz xcvt jrdp. Copy this password, and use it as your gmail password (without spaces).
If this doesn't help, also check logs, usually if there is a problem with smtp server, swiftmailer prints error to the logs.
'mailer_transport' is the protocole to send mails.
Try to use 'smtp' instead 'gmail' :)

Snc Redis bundle set password in config.yml

I set a password on my local redis server, but it gives the following error:
"NOAUTH Authentication required."
How can I configure a Redis password in config.yml?
You can specify it in your dsn config.
snc_redis:
clients:
default:
type: predis
alias: default
dsn: 'redis://%redis_session_secret%#%redis_host%:%redis_port%'
For me this DSN format worked:
redis://127.0.0.1?password=yourpass
snc_redis:
clients:
default:
type: predis
alias: default
dsn: 'redis://127.0.0.1?password=yourpass'
Found in Wiki https://github.com/nrk/predis/wiki/Connection-Parameters

Codeception - can't use DB module, because of invalid configuration

I've added DB module to acceptance suite.
And I've put:
modules:
config:
Db:
dsn: 'sqlite:storage/database.sqlite'
user:
password:
dump: tests/_data/dump.sql
in codeception.yml
Then i need to build:
cept build gives me:
[Codeception\Exception\ModuleConfig]
Db module is not configured!
Options: dsn, user, password are required
Please, update the configuration and set all the required fields
It's the same when I set user and password for dummy values.
I think sqlite doesn't need user and password - I can't get it work. I would appreciate any help, I'm clearly missing something.
You should set the user and password to empty values '' instead of nothing:
Db:
dsn: 'sqlite:storage/database.sqlite'
user: ''
password: ''
dump: tests/_data/dump.sql
try
modules:
enabled: [Db]
config:
Db:
dsn: 'sqlite:storage/database.sqlite'
user:
password:
dump: tests/_data/dump.sql
Db module requires user and password, these have filled

confirmation email not sent after registration in FOSUserBundle

My project is based on symfony 2.3.19 + lastest version version FOSUserBundle.
Actually, FOSuserBundle is working perfectly. In fact, all functionnalities are working correctly. Now, my goal is to activate the email confirmation when a user registers. For that, I configured my project in this way:
# app/config.yml
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
fos_user:
db_driver: orm
firewall_name: main
user_class: Minn\UserBundle\Entity\User
registration:
form:
type: minn_user_registration
confirmation:
enabled: true
template: MinnUserBundle:Registration:email.txt.twig
from_email:
address: XXXXXXX#gmail.com
sender_name: XXXXXXX
service:
mailer: fos_user.mailer.twig_swift
Checking this configuration, I get forwarded to /register/check-email with the message I wrote in MinnUserBundle:Registration:email.txt.twig. But no email was sent & no error was returned by symfony.
It there any idea?
Thanks,
It was just an error on SMTP credentials.... Thanks again....

Resources