I have two databases that I have to use in my application. I have the following in my mongoid.yml:
development:
# Configure available database sessions. (required)
sessions:
# Defines the default session. (required)
default:
# Defines the name of the default database that Mongoid can connect to.
# (required).
database: db_development
username: myusername
password: mypassword
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- myserverip:27017
databases:
secondary:
database: db2_development
username: myusername
password: mypassword
# Provides the hosts the default session can connect to. Must be an array
# of host:port pairs. (required)
hosts:
- myserverip:27018
In my model file:
class MyModel
include Mongoid::Document
store_in database: "secondary"
field :name, type: String
field :age, type: Integer
end
I have data in MyModel. When I tried to query, I'm go the following error:
Moped::Errors::QueryFailure (The operation: #<Moped::Protocol::Query
#length=96
#request_id=5
#response_to=0
#op_code=2004
#flags=[:slave_ok]
#full_collection_name="secondary.mymodel"
#skip=0
#limit=0
#selector={"name"=>"Tom"}
#fields=nil>
failed with error 10057: "unauthorized db:secondary ns:secondary.mymodel lock type:0 client:10.100.55.40"
I tried searching online but could not get any solution. Any help would be appreciated. Thanks in advance.
hmm well can you do this seem like you messed your yaml file
development:
sessions:
default:
database: db_development
username: my_username
password: my_password
hosts:
- myserverip:27017
options:
consistency: :eventual
writeable:
database: db2_development
username: myusername2
password mypassword2
hosts:
- myserverip2:27018
options:
consistency: strong
In your model just write this
store_in session: "writeable"
class MyModel
include Mongoid::Document
store_in session: "writeable"
field :name, type: String
field :age, type: Integer
end
FYI Never tested with password options but i guess it would work
Hope this help
In order to access a database temporarily (e.g. in a script) you can use the MongoDB Ruby drivers: Tutorials - Documentation - Low Level Documentation
For a quick overview:
Connect to the database:
client = Mongo::Client.new([ '127.0.0.1:27017' ], :database => 'my_db')
db = client.database
Query for entries via mongoDB query syntax:
db['collection_name'].find('field_name' => 'field_value')
Related
I'm following this tutorial to set up Authentication https://book.cakephp.org/authentication/2/en/index.html with CakePHP4.
The table where my users are stored is not called "users" so when I try to log in it gives me this error:
Base table or view not found: 1146 Table 'databasename.users'
Where can I specify the userModel? In which file should it be set up? How?
You have to configure the respective resolver accordingly, in this case the ORM resolver.
Resolvers are used by identifiers, which accept resolver configuration via the resolver option. So for example for the password identifier, you could do it like this:
$service->loadIdentifier('Authentication.Password', [
'resolver' => [
'className' => 'Authentication.Orm',
'userModel' => 'YourCustomModelName',
],
// ....
]);
Note that it's necessary to pass the class name too when passing an array of resolver configuration, as the default configuration is just a string (the resolver class name), so it will not merge with the defaults, but overwrite them!
See also
Authentication Cookbook > Identifiers
Authentication Cookbook > Identifiers > Identity resolvers
I am writing a k8s operator. In my CR file, I want to get password and store it in secret.
Everything works fine except this password gets printed on the screen when I describe my object kubectl describe myKind myObject is there any way to hide particular property from spec or at least show *** instead of actual value? just like secret it just shows bytes and not actual value.
Added line before my property // +kubebuilder:validation:Format=password. this add format: password in CRD file but when I describe myObject it still prints all Spec values on the console.
Edit: SO putting more light on this:
my **_types.go snipplet is:
// DB username
DbUser string `json:"dbUser,required"`
// DB password
// +kubebuilder:validation:Format=password
DbPassword string `json:"dbPassword,required"`
so I am making k8s secret out of dbUser and dbPassword
I have another option to ask users to create a secret as pre-req but I am not happy with that approach.
Thanks in advance.
You should NOT store passwords / tokens etc. in plain text in the CR. It will be visible to anyone with permissions to read the CR (no matter if k describe shows it or not).
I would recommend changing the CRD spec so users can reference their secret by name. Users will need to create a secret of type opaque then create a CR that looks something like this:
apiVersion: "grp/v1"
kind: "mykind"
metadata:
name: "my-kind-cr"
namespace: "default"
spec:
secretName: mysecret
where the secret would look like this:
apiVersion: v1
kind: Secret
metadata:
name: dbpassword
namespace: default
type: Opaque
stringData:
dbPassword: "my password"
I'm configuring the Pentaho 6.1 server to work with LDAP for the first time.
Which parameters do I need to change? And how?
I've tried to follow the instructions on this manual page:
https://help.pentaho.com/Documentation/6.1/0P0/150/010/030
After I change "provider=jackrabbit" to "provider=ldap" in the file: security.properties, when I try to enter on the Pentaho Login page with the administrator user, I get an error like the user doesn't exist.
This is my actual LDAP parameters:
Server host: ldap-sweft.ferint.kabal
Server port: 389
Use TLS connection: no
Bind DN: zenit
Bind Password: asddsa
Users base DN: dc=ferint,dc=kabal
Enable Group Retrieval: yes
Search scope: subtree
User authentication:
User search filter: (&(objectCategory=user)(sAMAccountName=$USER$))
Identity Attribute: sAMAccountName
Get all users filter: (objectCategory=user)
Group support:
Users of group filter: (&(objectCategory=user)(memberOf=$GROUP$))
Groups base DN: (vuoto)
Group Search Filter: (objectCategory=group)
Group Name Attribute: cn
Groups of user filter: (&(objectCategory=group)(member=$USER$))
This is how I changed the file: pentaho-solutions/system/applicationContext-security-ldap.properties
New file:
contextSource.providerUrl=ldap://ldap-sweft.ferint.kabal:389/
contextSource.userDn=dc\=ferint\\zenit
contextSource.password=asddsa
userSearch.searchBase=ou\=Utenti,dc\=ferint,dc\=kabal
userSearch.searchFilter=(sAMAccountName\={0})
populator.convertToUpperCase=false
populator.groupRoleAttribute=cn
populator.groupSearchBase=ou\=Gruppi,dc\=ferint,dc\=kabal
populator.groupSearchFilter=(member:1.2.840.113556.1.4.1941:={0})
populator.rolePrefix=
populator.searchSubtree=true
allAuthoritiesSearch.roleAttribute=cn
allAuthoritiesSearch.searchBase=ou\=Gruppi,dc\=ferint,dc\=kabal
allAuthoritiesSearch.searchFilter=(objectClass\=organizationalRole)
allUsernamesSearch.usernameAttribute=sAMAccountName
allUsernamesSearch.searchBase=ou\=Utenti,dc\=ferint,dc\=kabal
allUsernamesSearch.searchFilter=objectClass\=person
adminRole=cn\=Administrator,ou\=roles
adminUser=cn\=zenit,ou\=Chiavi\ esoteriche,dc\=ferint,dc\=kabal
Original file:
contextSource.providerUrl=ldap\://localhost\:10389/ou\=system
contextSource.userDn=uid\=admin,ou\=system
contextSource.password=secret
userSearch.searchBase=ou\=users
userSearch.searchFilter=(cn\={0})
populator.convertToUpperCase=false
populator.groupRoleAttribute=cn
populator.groupSearchBase=ou\=roles
populator.groupSearchFilter=(roleOccupant\={0})
populator.rolePrefix=
populator.searchSubtree=false
allAuthoritiesSearch.roleAttribute=cn
allAuthoritiesSearch.searchBase=ou\=roles
allAuthoritiesSearch.searchFilter=(objectClass\=organizationalRole)
allUsernamesSearch.usernameAttribute=uid
allUsernamesSearch.searchBase=ou\=users
allUsernamesSearch.searchFilter=objectClass\=Person
adminRole=cn\=Administrator,ou\=roles
What parameters should I change?
pentaho-solutions/system/data-access/settings.xml
pentaho-solutions/system/pentaho.xml
pentaho-solutions/system/repository.spring.properties
pentaho-solutions/system/applicationContext-spring-security.xml
The issue is that I am unable to connect to oracle database from the Carbon console while creating a datasource to a schema. The error is:
ERROR - DataServiceAdmin Could not connect to database jdbc:oracle:thin:#localhost:1522/ORADB12c with username WSO2_TUT
java.sql.SQLException: ORA-28040: No matching authentication protocol
I have a local installation of an Oracle database (12c). I would like to create a datasource on Carbon for a schema I have created on this database.
While providing the connection parameters I have selected to test the connection and the above error occurs.
I have added ojdbc6, then deleted and added ojdbc7 instead, then deleted and replaced with ojdbc14 to the directory of the WSO2 Enterprise Integrator:
D:\WSO2\EnterpriseIntegrator\6.5.0\lib
After that I restarted the server. When trying to re-create the datasource with the same credentials, I get this authentication error for some reason.
The connection details:
Datasource Id* oracle_DS
Datasource Type* RDBMS
Database Engine* Oracle
Driver Class* oracle.jdbc.driver.OracleDriver
URL* jdbc:oracle:thin:#localhost:1522/ORADB12c
User Name WSO2_TUT
Password ********
I don't know what's missing here, any help is greatly appreciated!
Thank you in advance
Regards,
Not sure if it helps, but here's the configuration that I use to connect to a oracle 11 database.
Datasource Type: RDBMS
Datas Sourec Provider: default
Driver: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:thin:#hostname:1521:TNS_Listener
User name: myUser
Password: myPassword
I'm attempting to follow along with a tutorial located at http://serverless-stack.com/chapters/create-a-cognito-identity-pool.html for identity pool creation and document the creation by using cloudformation so that I can easily undo everything when I am done. However, I am having trouble finding any examples that show how to effectively do this using the template syntax. What I currently have is the following
ScratchUserPool:
Type: AWS::Cognito::UserPool
Properties:
UserPoolName: notes-user-pool
ScratchUserPoolClient:
Type: AWS::Cognito::UserPoolClient
Properties:
ClientName: notes-client
ExplicitAuthFlows: [ADMIN_NO_SRP_AUTH]
UserPoolId:
Ref: ScratchUserPool
ScratchIdentityPool:
Type: AWS::Cognito::IdentityPool
Properties:
IdentityPoolName: ScratchIdentityPool
AllowUnauthenticatedIdentities: false
CognitoIdentityProviders:
- ClientId:
Ref: ScratchUserPoolClient
ProviderName:
Ref: ScratchUserPool
The deployment step is failing when it attempts to create the ScratchIdentityPool. I get an error stating that:
An error occurred while provisioning your stack: ScratchIdentityPool -
Invalid Cognito Identity Provider (Service: AmazonCognitoIdentity;
Status Code: 400; Error Code: InvalidParameterException; Request ID:
bc058020-663b-11e7-9f2a-XXXXXXXXXX)
Am I not referencing the Client or Provider name correctly?
Almost immediately after I posted my question, I think I was able to answer it. The problem with my identity pool is that I needed to reference the provider name in the following way:
ScratchIdentityPool:
Type: AWS::Cognito::IdentityPool
Properties:
IdentityPoolName: ScratchIdentityPool
AllowUnauthenticatedIdentities: false
CognitoIdentityProviders:
- ClientId:
Ref: ScratchUserPoolClient
ProviderName:
Fn::GetAtt: [ScratchUserPool, ProviderName]
I needed to use the special amazon function Fn::GetAtt in order for this to work.