Closed rsurdikar closed 3 years ago
Hello @rsurdikar ,
Please check the following comment on one of the similar issue I raised earlier.
https://github.com/OHDSI/WebAPI/issues/1099#issuecomment-505424385
You need to create a new schema within OHDSI database and store the credentials there first , ensure that passwords are bcrypted using bcrypt utility https://www.browserling.com/tools/bcrypt
Login to Atlas with the username and password after giving a user admin privileges role_id 2 in webapi.sec_user table.
Thanks @ambuj369 for quick reply.
Currently I have created 'demo_security' table under 'webapi' schema. Let me try moving it to new schema.
Also, you have mentioned following changes in that comment, let me try those as well.
- In demo_security table I have used the column "username" instead of "email" because username is mentioned within the JDBCAuthRealm.Java code
- Update the settings.xml for authentication query section -
select password,firstName,middleName,lastName from atlas_security.demo_security where email = ?
@ambuj369 I did all the above suggested changes (separated security schema, updated settings.xml) but still I am facing the same issue.
REST API http://localhost:8080/WebAPI/user/me
throwing 403 error.
Also, I observed that, REST API http://localhost:8080/WebAPI/user/login/db
always returns me permissions related to 'public' role, even though I have assigned 'admin' role to my user.
Note: I tried to give all admin permission to 'public' role but still no luck.
Here is my DB screen-shot:
My settings.xml
<settings>
<profiles>
<profile>
<id>webapi-mssql</id>
<properties>
<datasource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</datasource.driverClassName>
<datasource.url>jdbc:sqlserver://localhost:1433;databasename=synpuf52</datasource.url>
<datasource.username>sa</datasource.username>
<datasource.password>password</datasource.password>
<datasource.dialect>sql server</datasource.dialect>
<datasource.ohdsi.schema>webapi</datasource.ohdsi.schema>
<flyway.datasource.driverClassName>${datasource.driverClassName}</flyway.datasource.driverClassName>
<flyway.datasource.url>${datasource.url}</flyway.datasource.url>
<flyway.datasource.username>sa</flyway.datasource.username>
<flyway.datasource.password>password</flyway.datasource.password>
<flyway.locations>classpath:db/migration/sqlserver</flyway.locations>
<security.provider>AtlasRegularSecurity</security.provider>
<security.enabled>true</security.enabled>
<security.origin>*</security.origin>
<security.ssl.enabled>false</security.ssl.enabled>
<security.cors.enabled>true</security.cors.enabled>
<security.maxLoginAttempts>3</security.maxLoginAttempts>
<security.duration.initial>10</security.duration.initial>
<security.duration.increment>10</security.duration.increment>
<security.db.datasource.url>jdbc:sqlserver://localhost:1433;databasename=synpuf52</security.db.datasource.url>
<security.db.datasource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</security.db.datasource.driverClassName>
<security.db.datasource.schema>webapi</security.db.datasource.schema>
<security.db.datasource.username>sa</security.db.datasource.username>
<security.db.datasource.password>password</security.db.datasource.password>
<security.db.datasource.authenticationQuery>select password,firstname,middlename,lastname from security.atlas_security.demo_security where username = ?</security.db.datasource.authenticationQuery>
</properties>
</profile>
</profiles>
</settings>
@rsurdikar
Thanks @ambuj369 for the comments.
My role issue is resolved now, It's picking up permissions correctly based on the given role but still
REST API http://localhost:8080/WebAPI/user/me
throws 403 error.
My updated settings.xml
<settings>
<profiles>
<profile>
<id>webapi-mssql</id>
<properties>
<datasource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</datasource.driverClassName>
<datasource.url>jdbc:sqlserver://localhost:1433;databasename=synpuf52</datasource.url>
<datasource.username>sa</datasource.username>
<datasource.password>password</datasource.password>
<datasource.dialect>sql server</datasource.dialect>
<datasource.ohdsi.schema>webapi</datasource.ohdsi.schema>
<flyway.datasource.driverClassName>${datasource.driverClassName}</flyway.datasource.driverClassName>
<flyway.datasource.url>${datasource.url}</flyway.datasource.url>
<flyway.datasource.username>sa</flyway.datasource.username>
<flyway.datasource.password>password</flyway.datasource.password>
<flyway.locations>classpath:db/migration/sqlserver</flyway.locations>
<security.provider>AtlasRegularSecurity</security.provider>
<security.enabled>true</security.enabled>
<security.origin>*</security.origin>
<security.ssl.enabled>false</security.ssl.enabled>
<security.cors.enabled>true</security.cors.enabled>
<security.maxLoginAttempts>3</security.maxLoginAttempts>
<security.duration.initial>10</security.duration.initial>
<security.duration.increment>10</security.duration.increment>
<security.db.datasource.url>jdbc:sqlserver://localhost:1433;databasename=security</security.db.datasource.url>
<security.db.datasource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</security.db.datasource.driverClassName>
<security.db.datasource.schema>atlas_security</security.db.datasource.schema>
<security.db.datasource.username>sa</security.db.datasource.username>
<security.db.datasource.password>password</security.db.datasource.password>
<security.db.datasource.authenticationQuery>select password,firstname,middlename,lastname from atlas_security.demo_security where username = ?</security.db.datasource.authenticationQuery>
</properties>
</profile>
</profiles>
</settings>
@rsurdikar Please try to login with the credentials you've stored in security database.
@ambuj369
yes, I have used same credentials i.e. sa/password from security database and also, I see REST API http://localhost:8080/WebAPI/user/login/db is returning 200 response.
But on tomcat console, I see following logs.
2019-10-09 16:02:56.054 INFO http-nio-8080-exec-1 org.apache.shiro.realm.AuthorizingRealm - - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.
2019-10-09 16:02:56.054 INFO http-nio-8080-exec-1 org.apache.shiro.realm.AuthorizingRealm - - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.
2019-10-09 16:02:56.054 INFO http-nio-8080-exec-1 org.apache.shiro.realm.AuthorizingRealm - - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.
2019-10-09 16:02:56.054 INFO http-nio-8080-exec-1 org.apache.shiro.realm.AuthorizingRealm - - No cache or cacheManager properties have been set. Authorization cache cannot be obtained.
2019-10-09 16:02:56.054 WARN http-nio-8080-exec-1 org.ohdsi.webapi.shiro.ADRealm - - LDAP naming error while attempting to retrieve authorization for user [sa].
Not sure, If above error is related ?
@rsurdikar from the first comment, the screenshot says the username you added is "ohdsi", please use that login name with its respective password.
@ambuj369
yes, you are right previously, I used 'ohdsi/ohdsi' credential but now, I changed to 'sa/password' (thinking it should be same as that of database user/password).
Also, If login credential is the issue then REST /user/login/db
would have failed, but it passes.
@rsurdikar Good to hear that. We need to mention security DB password in settings.xml so that webapi could get access to the security database and its tables. However, the credentials entered in security database, is the key to Atlas.
Thanks @ambuj369 for the help.
Sorry, but REST API http://localhost:8080/WebAPI/user/me still throws 403 error, I guess I need to debug webapi source code to understand what's exactly happening.
I will post my findings.
@rsurdikar Yes Basic security still has this issue. I am using my old findings to fix this issue.
Also just FYI, bcrypt link that in mentioned in the wiki is not working for me any more I tried other links and WebAPI is not able to verify the hash refer #1350. I am not sure which bcrypt algorithm was used in the link that got deprecated.
Thanks @ChavanShweta for the reply. I guess, I need to customise source code for now to fix this issue.
Thanks @ambuj369 for the help.
Sorry, but REST API http://localhost:8080/WebAPI/user/me still throws 403 error, I guess I need to debug webapi source code to understand what's exactly happening.
I will post my findings.
FWIW, I found the following SQL statement resolved the 403 error for me.
DECLARE @next_sec_role_permission_id INT, @permission_user_me_get INT
SELECT @next_sec_role_permission_id=max(id)+1
FROM [TrioOMOP].[ohdsi].[SEC_ROLE_PERMISSION]
SELECT @permission_user_me_get=id FROM [TrioOMOP].[ohdsi].[SEC_PERMISSION] WHERE [value]='user:me:get'
-- add user:me:get permissions to admin user role
INSERT INTO [TrioOMOP].[ohdsi].[SEC_ROLE_PERMISSION] (id,[ROLE_ID],[PERMISSION_ID])
VALUES (@next_sec_role_permission_id,2,@permission_user_me_get)
Wiki updated to reflect this information.
@anthonysena could you please help to fix below ldap/AD issue. https://forums.ohdsi.org/t/ldap-authentication-is-not-working/14954
root@:~/OHDSI/Broadsea/postgresql# cat docker-compose.yml version: '2'
services:
broadsea-methods-library: image: ohdsi/broadsea-methodslibrary ports:
PASSWORD=mypass
broadsea-webtools: image: ohdsi/broadsea-webtools ports:
security_ad_searchFilter="(&(objectClass=person)(uid=*))" root@:~/OHDSI/Broadsea/postgresql# cat config-local.js define([], function () { var configLocal = {};
// clearing local storage otherwise source cache will obscure the override settings
localStorage.clear();
var getUrl = window.location;
var baseUrl = getUrl.protocol + "//" + getUrl.host;
// WebAPI
configLocal.api = {
name: 'OHDSI',
url: 'https://10.175.158.228:443/WebAPI/'
};
configLocal.cohortComparisonResultsEnabled = false;
configLocal.userAuthenticationEnabled = true;
configLocal.plpResultsEnabled = false;
configLocal.authProviders = [{
"name": "Local Security Test DB",
"url": "user/login/db",
"ajax": true,
"icon": "fa fa-database",
"isUseCredentialsForm": true
},
{
"name": "AD",
"url": "user/login/ad",
"ajax": true,
"icon": "fa fa-cubes",
"isUseCredentialsForm": true
}];
return configLocal;
}); root@:~/OHDSI/Broadsea/postgresql#
Hi,
I am trying to add basic security in Atlas by referring to the following documentation:
https://github.com/OHDSI/WebAPI/wiki/Basic-Security-Configuration https://github.com/OHDSI/WebAPI/wiki/Atlas-Security
I am able to login but not able to access any atlas pages, Not sure what I have missed?
Sorry for lengthy description, giving details of what things I have observed:
Login Request:
Form Data:
Request Headers:
Response Headers:
Response:
Permission Request:
Request Headers:
Response Headers:
Console error:
source of error AuthAPI.js:
I see my tomcat server logs mention following warnings and error:
Atlas config-local.js
WebAPI settings.xml
demo_security Table:
SEC_USER table:
SEC_ROLE table:
SEC_USER_ROLE table (Tried with every possible role):
http://localhost:8080/WebAPI/info {"version":"2.4.2"}
Please look into above issue and let me know if I have missed anything? Is it related to error 'LDAP naming error while attempting to retrieve authorization for user [ohdsi]'? why it's showing?
Thanks, Rohan
@ambuj369 @anthonysena @chrisknoll @ChavanShweta @ssuvorov-fls