unable to login in modx manager after migration - modx

I'm using ModX Revo 2.6
I moved my site from another hosting and it's work fine, but now I can't log in into manager.
I triple checked that password is correct, I tried to reset it via email, even change it in DB - nothing helped, I still get the message that login or password is incorrect.
Also, here is the API script to reset password, but it returns me that user does not exist.
Also when I try to reset it via email it doesn't change in DB, even I still got the message with new one.
What should I do?

Well, I end up reinstalling clear version and then merge all db tables except users and user_attributes and now I can enter with account I made wile install.

Try to clean up /core/cache/ folder, and set 777 to it.
Check database setting in /core/config/config.inc.php Make sure that all settings is correct (check all uppercase places in my example!)
$database_type = 'mysql';
$database_server = 'localhost';
$database_user = 'USERNAME';
$database_password = 'PASSWORD';
$database_connection_charset = 'utf8';
$dbase = 'DBNAME';
$table_prefix = 'modx_';
$database_dsn = 'mysql:host=localhost;dbname=DBNAME;charset=utf8';
In addition, check absolute folders in /core/config/config.inc.php
For example:
if (!defined('MODX_CORE_PATH')) {
$modx_core_path= '/absolute/path/to/your/website.com/core/';
define('MODX_CORE_PATH', $modx_core_path);
}
Also, you can reinstall MODx at new server. Download last version, upload to server (rewrite all files) and go to your-website.com/setup and follow instructions. Don't forget to make backup.

Related

Error Message: MongoError: bad auth Authentication failed through URI string

I'm trying to connect to my mongoDB server via the connection string given to me by mongo:
"mongodb+srv://david:password#cluster0-re3gq.mongodb.net/test?retryWrites=true"
In my code I am calling the connection through mongoose like this (obviously putting in my password):
const mongoose = require('mongoose');
const db = 'mongodb+srv://david:<password>#cluster0-re3gq.mongodb.net/test?retryWrites=true'
mongoose
.connect(db, {
useNewUrlParser: true,
useCreateIndex: true
})
.then(() => console.log('MongoDB connected...'))
.catch(err => console.log(err));
When I run the code I am getting the following error
"MongoError: bad auth Authentication failed."
Any ideas of what that could mean?
I had the same problem, and in my case, the answer was as simple as removing the angle brackets "<"and ">" around <password>. I had been trying: my_login_id:<my_password>, when it should have been my_login_id:my_password.
I think you're confused with the mongodb account password and user password.
You should use user password, not account password.
That was the reason of my case.
It happens because your provided password in connection string is wrong and most probably you have mistaken cluster password with your login password, in simple words while connecting with Atlas Cluster we can't use our account password by which we login to the Atlas website. In both case we can reset our cluster password and solve this issue.
To Solve The Issue Follow Below Given Steps
Step 1:- Click Database Access From left Side Navigation of MongoDB Atlas page.
Step 2:- Select your username and and click on the edit button from right side.
Step 3:- Click to change password.
Step 4:- Click update user.
While changing password try to keep password only alphabetical because special characters need encoding.
that's all now you can connect.
Don't use creds in the URI, use like this instead:
mongoose.connect(mongodb+srv://clusterAnything.mongodb.net/test?retryWrites=true&w=majority, { user: process.env.MONGO_USER, pass: process.env.MONGO_PASSWORD, useNewUrlParser: true, useUnifiedTopology: true })
In my case left and right characters are there
like this:
<Password>
so changed to:
Password
Checklist to follow:
1) Make sure you're using the correct password (the DB user password and not the Mongo account).
2) When entering your password, make sure all special characters are URL encoded (for example: p#ssword should be p%40ssword).
3) If you don't remember your password of your DB user - go to Database Access (if you're using Mongo Atlas) -> select your DB user -> edit -> create a new password -> don't forget update to click on 'Update User'.
(!) Security warning: Do not write the password in plain text inside your code - Follow the suggestions given here.
Are you writing your password in the place of <password>? If your aren't, a good practice is to create a environment variable on your operating system and call it using process.env.[your variable]. Ex:
const password = process.env.YOURPASSWORDVARIABLE
const db = 'mongodb+srv://david:'+password+'#cluster0-re3gq.mongodb.net/test?retryWrites=true'
Better yet, you can also put your whole url connection string inside a env variable:
Adding to above answers, the issue seemed to revolve around a wrong Database password input for me, because of a distortion of what i read as my current password from the Atlas menu and what MongoDB Atlas really saved as my current password.
There seems to be a "bug" when using the "Copy" button when choosing a new password.
What helped me was the following:
Open Atlas in the web
Go to "Database Access"
Click "Edit" on the Database user
Choose "Password" for authentication method
Click "Edit Password"
Click "Show" in the password field
Click "Autogenerate Secure Password"
DO NOT press "Copy" button to copy, but use manual selection via mouse and copy the text via right-click of your mouse or keyboard command
Click "Update User" below
Then:
Go through the list of Database users to make sure that no other Database user has the same password you just newly generated.
Now try your Username/Password combination again using this connection string (leaving out the placeholder characters '$' and '[]':
'mongodb+srv://$[username]:$[password]#$[hostlist]/$[database]?retryWrites=true'
I noticed that when I autogenerated a new password by clicking and then clicking the "Copy" button, that the autogenerated password was reset to the old password. Therefore I assumed the new autogenerated password is correct, but in reality it was my old password, which in addition was the same as for another Database user. I could not comprehend that until I clicked "Show" on the password input field.
Not only the password
Check all the fields it could be the password the user or the database. If you misspelt any of these you will have an authentication error.
Go to the database access on the left pane under security:
And in case change the password using edit button. Let's say your password is: P#sW0rd
You can compile the URL using the information contained in the Database Users screen:
client = MongoClient("mongodb+srv://giac:P#sW0rd#cluster0.wjdtk.mongodb.net/testc?retryWrites=true&w=majority")
The other answers did not say that even if you mispell the database name you have a authentication error.
This worked for me
mongoose.connect(
`mongodb+srv://${process.env.MONGO_USER}:${process.env.MONGO_PASS}#cluster0.adv0t.mongodb.net/${process.env.MONGO_DATABASE}?retryWrites=true&w=majority`,
{
useNewUrlParser: true,
useUnifiedTopology: true,
}
);
Create a ".env" file (you need to install dotenv before this ) in the parent directory(if you choose a custom location, add the following in server.js / app.js).
require('dotenv').config({ path: '/custom/path/to/.env' }) //uses custom location
Otherwise, add this in the server.js / app.js (the one that initiates server).
require('dotenv').config() //uses default location
In the ".env" file, define the user, password and database like this
MONGO_USER=uSerName
MONGO_PASS=p#sSW0rd
MONGO_DATABASE=myDatabase
I faced a similar issue, weirdly enough it got resolved when I created a new user in database access. This time though I clicked on autogenerate password. It should not matter but in my case it solved the issue.
I forgot to update the user after generating and copying the password and was wondering why it wasn't working. I saw the update button later. I was not visible to me earlier. lol. Solved the problem.
Database Access => edit user => generate/copy password => update it!
It worked for me.
remember to make sure you have updated it.
Just remove the angle brackets from both sides of your password.
Wrong Answer :
const db = 'mongodb+srv://username:<password>#cluster0-re3gq.mongodb.net/test?retryWrites=true'
Correct Answer :
const db = 'mongodb+srv://username:password#cluster0-re3gq.mongodb.net/test?retryWrites=true'
Finally, it worked for me to used that connection string with a lower grade that NodeJs versions(2.2.12 or later) cluster url. And After that make sure you have to whitelist your current IP Address from Atlas MongoDB. It should display like 0.0.0.0/0 (includes your current IP address) in Network Access section in Atlas MongoDB.
Connect to cluster NodeJs version 2.2.12 or later
And the main issue was where I am storing that connection string url in a constant that part. So initially,I was storing that connection string value in single/double quote but every time I was getting Authentication failure error as it was unable to parse that "Password" value from Atlas mongoDB . So I used backtick (``)instead of single/double quote to store that connection string.
Sample code where I am connecting mongoDB Atlas through a NodeJs application.
const DB_USER = 'your username in atlas mongodb';
const PASSWORD = encodeURIComponent('your password in atlas mongodb');
const url = `mongodb://${DB_USER}:${PASSWORD}#cluster0-shard-00-00.3ytbz.mongodb.net:27017,cluster0-shard-00-01.3ytbz.mongodb.net:27017,cluster0-shard-00-02.3ytbz.mongodb.net:27017/sample-db?ssl=true&replicaSet=atlas-z26ao5-shard-0&authSource=admin&retryWrites=true&w=majority`;
mongoose.connect(url,
{
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: true
})
.then(() => {
console.log('Connected to database !!');
})
.catch((err)=>{
console.log('Connection failed !!'+ err.message);
});
I just had this problem knowing that I was using the correct username, password and DBname.
I tried to change the password for the db user to double check, but it still didn't work.
I then instead created a new user, gave the user admin role, set the password etc, and then used that new user and password (same dbname) for the connection and it worked.
I don't know exactly what the issue was, but hoping it can help some of you save some time :)
After spending almost an hour messing with the URI, changing permissions and configurations and whatnot, I found out I was getting this error message because of a VPN connection I had active. After shutting down the VPN I was able to connect.
So if nothing else works for you, there might be something in your system preventing a connection to be successfully established and mongodb is just responding with bad auth
I had this same challenge but I discovered that making my IP address set to my current IP prevented me from accessing the services. Making the database accessible from anywhere was appropriate to access the database either using mongo shell or mongo compass.
The same problem i faced with mongoDB password authentication failed.
"Error: bad auth Authentication failed."
As per Pawan's suggestion given above i replaced my login password in MONGO_URI link with database password and it works. be sure to check that one also.
If you not generated the generate new one or if created earlier then replace with new one.
In my case, my password was wrong, to diagnostic the error, I have been follow the next steps:
I have to try connection by command line:
Whit this command: mongo "mongodb+srv://cluster0-j8ods.mongodb.net/test" --username :
The response was again: 2020-04-26T11:48:27.641-0500 E QUERY [js] Error: bad auth Authentication failed. :
then I'm change the password for my user, in my case, root user. and thats it, I'm authorized
mongodb+srv://jehat123:<password>#jehatarmancdeniz-x2yf7.mongodb.net/question-answer?retryWrites=true&w=majority
Delete all of password part
Use like this:
mongodb+srv://jehat123:yourpass#jehatarmancdeniz-x2yf7.mongodb.net/question-answer?retryWrites=true&w=majority
You can also get rid of this error by creating a new database user by going to Database Access from the left side and then go to Add New Database User from right right.
Now create a new username and password, click OK. Now replace this new username and password into the MongoUri.
In My case the above error got resolved by setting password variable directly.
DATABASE = "test"
#PASSWORD = os.environ.get("YOUR_PASSWORD") #This line was causing an error in code
PASSWORD = "YOUR_PASSWORD" # I added directly password variable
client = connect(
DATABASE,
host=f"mongodb+srv://mano:{PASSWORD}#cluster0.e2arj.mongodb.net/?retryWrites=true&w=majority",
alias="default",
)
Changing password worked for me
nB: Not the atlas password
mongodb+srv://david:password#cluster0-re3gq.mongodb.net/test?retryWrites=true
Replace 'password' with the password you registered for the username specified.
Replace 'test' after net with the name of the db you created in collections.
For me it turned out to be, that I had to tab out of the password field on the MongoDB Atlas page. Before clicking "Update User"
Just go to the "MongoDB Users tab" where you will find the user list. Click on edit where you can reset the password. Sometimes resetting the password can resolve the issue.
if you having this issue and learning mongo by official mongo trainings use m001-mongodb-basics as password for your db. And the correct db name is Sandbox (if you followed all steps)
This happened to me recently, I found out if you have updated your Mongo Db Password recently, your older databases will still be using the old password.
You can get around this by adding a new user to your Mongo db account or just use the old password.
Go to Database on the left hand side
click on browse collection
click on Add My Own Data
provide database name and collection name
Again click on database
click on connect ,connect your application
Select node.js
copy the connection string and keep it in your server.js
9)click on database access , edit password, autogenerate password
Copy the password with mouse , click update user
replace in the url string with this password and you are done
First, check your password(regenerate)
if not solved.
please check your MongoDB connect URL
this piece of code is unique,
mongodb+srv://reduxJobBox:<password>#cluster0.b08r8ak.mongodb.net/?retryWrites=true&w=majority

How to enable images and documents upload in MediaWiki without login

I am working in project for documenting diffrent documentation in my company. For that purpose I have installed MediaWiki that will be avaliable only for domain users - not from outside company.
So I whant that no loggin is needed, so every user in domain could edit articles, upload documents, images. So fare everyone can edit text, but cannot upload documents and images if user is not logged in.
I have try in LocalSettings.php this:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = true;
But after refresh server, still when try to upload file or image, it says, that I need to be logged in to upload.
What sould I more do, to enable upload without log in.
Try this as mentioned in Documentation
$wgGroupPermissions['*']['upload'] = true;
This might also be useful to avoid problems in the future
$wgGroupPermissions['*']['reupload'] = true;

Nextcloud external login for users in another database

I have a Nextcloud installation, with users stored in an external database, and this works fine with this app : https://apps.nextcloud.com/apps/user_sql
With that in place, I can login on my Nextcloud instance via the login form provided by Nextcloud.
I need to autolog the users when they come from another app.
I've written a PHP script, placed at the root of my Nextcloud installation, and it gets called by other internal apps of my company.
This script receives a userId and a token in the URL. After a successful check (no need to get in the details here), this script should log the user in.
Which API should I call to get the user logged in?
I tried the following, without success:
OC_User::login(...)
OC_User::getUserSession()->login(...)
Is there a way to trigger a valid login, so that I can get the users logged in?
Thank you for your answers, guys!
$user = '';
$pass = '';
$s = \OC::$server->getUserSession();
if (!$s->isLoggedin()) $s->login($user, $pass);
else $s->logout();
Placing this at /index.php and before calling OC::handleRequest() does the trick. It doesn`t work as expected but you could try to continue from here.
PD: Nextcloud Server v14.0.0 Alpha

LDAP with gitlab: Undefined method persisted

I'm currently setting up a gitlab server using a LDAP backend.
When I try to login as a user present in the LDAP db, I get the following error:
"Could not authorize you from LDAP because: "Undefined method 'persisted?' for #"
Peeking into the source code (specifically app/controllers/omniauth_callbacks_controller.rb) the villain seems to be:
#user = Gitlab::LDAP::User.find_or_create(oauth)
#user.remember_me = true if #user.persisted?
It is totally correct for him to fail here because there is no method persisted? (neither in lib/gitlab/ldap/user.rb nor lib/gitlab/oauth/user.rb). Changing the second line to
#user.remember_me = false #true if #user.persisted?
doesn't work either since remember_me is an invalid function for ruby.
I really have no clue about ruby, let alone Ruby On Rails, so I stopped digging here.
Since I certainly am not the first person to try using LDAP auth in gitlab I consider this an error on my side. Since authentication seems to work (if I enter a false password for the user gitlab happily tells me so), I don't have any idea where to start looking.
I appreciate any help from you guys,
Best Richard
Edit: My gitlab.yml is here.
Solved the problem myself. The database lookup yielded a nil object due to the user creation failing (whenever a ldap user logs in, gitlab uses the ldap data to fill its own database).
During creation of the user database entry the query got an invalid email entry resulting in a failed insert query. Unfortunately this was very hard to debug.
In case anyone should have this problem, try changing the following code in lib/gitlab/oauth/user.rb:
begin
user.save!
rescue ActiveRecord::RecordInvalid => e
raise_error ("(OAuth) Error #{e.to_s}") # <-- add this line
log.info "(OAuth) Email #{e.record.errors[:email]}. Username #{e.record.errors[:username]}"
return nil, e.record.errors
end
This will - in case gitlab is not able to add your user - print the error message the database backend returned as the usual red error banner when trying to log in. Keep in mind to remove this line when you no longer need it.
I can suggest a patch (tested on Gitlab 7.1.0). This code sets the gitlab_rails['ldap_uid'] as username when a ldap user is connecting for the first time :
in /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/oauth/user.rb (see INCLUDE START and STOP) :
user = model.build_user(opts)
user.skip_confirmation!
# Services like twitter and github does not return email via oauth
# In this case we generate temporary email and force user to fill it later
if user.email.blank?
user.generate_tmp_oauth_email
elsif provider != "ldap"
# Google oauth returns email but dont return nickname
# So we use part of email as username for new user
# For LDAP, username is already set to the user's
# uid/userid/sAMAccountName.
email_username = email.match(/^[^#]*/)[0]
# Strip apostrophes since they are disallowed as part of username
user.username = email_username.gsub("'", "")
else
# INCLUDE START
# if LDAP config "ldap_uid" is set : we pick this attribute to set the username :
if ldap_conf['uid'].present?
user.username = auth.extra.raw_info.send(ldap_conf['uid'])[0]
end
# INCLUDE STOP
end
begin
user.save!
In my case the problem was importing (copying file) fro old gitlab repositories to new one.
Gitlab wasn't able to create clean folder for the new user.
Solution:
remove imported repositories
create new, empty repository by first login with LDAP credentials
read your PRIVATE-TOKEN
start gitlab server on your repository ie. 'git daemon --verbose --export-all'
import data from old gitlab using API:
curl -X POST --header "PRIVATE-TOKEN: xxxxxffxxxyyxxxxzzz" http://testserver07.lq/api/v3/projects"?name=project01&import_url=git://localhost/var/opt/gitlab/git-data/repositories-old/repos/project01.git"
First, check if your email address in Gitlab DB is correct:
# login to Gitlab DB (MySql)
mysql -u gitlab gitlabhq_production -p
# check user email address
select email from users where username like 'foo';
Then remove stored LDAP objects from Gitlab DB for the user:
# clear ldap data
update users set extern_uid = '' where username = 'foo';
On next login Gitlab write a new extern_uid.

How to use a logged in person's credentials to search Active Directory?

I have a web app (.NET 3.5) which is sending notifications by email to users. In order to do this, I search Active Directory to find each person's email.
At the moment, I am hardcoding my own username and password like so in order to search AD:
Dim entry As New DirectoryEntry("LDAP://companyad", "myUsername", "myPassword", AuthenticationTypes.Secure)
Dim srch As New DirectorySearcher(entry)
srch.Filter = [String].Format("(&(objectClass=person)(sAMAccountName={0}))", "someOtherUsername")
Dim result As SearchResult = srch.FindOne()
Now, obviously, this is not ideal and I don't want those credentials hardcoded. My web app is using Windows Authentication. It also uses impersonation (as the logged in user) to access files and SQL Server. Is there also a way for me to "impersonate" the logged in user in order to search AD?
EDIT 1
I thought I'd better explain why I chose this answer. The problem turned out to not be the multi-hop issue or kerberos as it seems I have set these up correctly.
I had recently changed my app to only allow access to a certain group through the web.config settings. I had previously been only allowing access to myself. I set up the group and added myself to it. I then removed the hardcoded credentials and attempted to run the app WITHOUT RESTARTING my computer.
According to my network admin, I would not be logged on under that new group until I restarted my computer which I think is what was causing my problem. So, Preet's answer is actually the most accurate as I just needed to pass the LDAP path to DirectoryEntry.
EDIT 2
I also needed to register a Service Principal Name.
I ran this:
setspn -A HTTP/[dns name of the site] [machine name]
on my development machine.
Thanks to everyone else for their answers.
Doesn't
Dim entry As New DirectoryEntry("LDAP://companyad")
work?
Why not create a new user for this purpose alone? A user with only searching rights.
I set <identity impersonate="true"/> in my web.config and added the following code to my my page load event handler. It worked fine. Are you sure you are not dealing with a multi hop situation? In that case your app pool account needs to be configured for kerberos authentication to support impersonation in a multihop scenario. More info on this is here: http://support.microsoft.com/kb/329986
Response.Write(User.Identity.Name);
DirectoryEntry entry = new DirectoryEntry("LDAP://[mydomain.net]");
DirectorySearcher srch = new DirectorySearcher(entry);
srch.Filter = string.Format("(&(objectClass=person)(sAMAccountName={0}))", "[user]");
SearchResult result = srch.FindOne();
Response.Write(result.Path);
If you wish to use the Windows logged in user account as the credentials against AD, you have to use the following:
public bool IsExistingUser() {
DirectoryEntry de = new DirectoryEntry(Environment.UserDomainName)
DirectorySearcher ds = new DirectorySearcher(de)
ds.Filter = string.Format("((objectClass=user)(SAMAccountName={0}))", Environment.UserName)
try
SearchResult sr = ds.FindOne();
if (sr != null && sr.DirectoryEntry.Name.Contains(Environment.UserName))
return true;
catch (DirectoryServicesCOMException ex)
catch (COMException ex)
throw new Exception("Can't find logged in user in AD", ex);
return false;
}
Assuming this code would compile and run, it will verify whether the existing logged in user is known by your Domain Controller.
Impersonation is discouraged as it lets litteral password strings travel in your network. So, try to avoid it as much as possible.
EDIT Here's a pretty useful link for AD: Howto: (Almost) Everything In Active Directory via C# I found this post awesome!

Resources