Cakephp: Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long while setting the cookies - cakephp

I am enabling cookies on my cakephp app as mentioned in the documentation problem is i am getting the security error while setting the cookies.
Invalid key for encrypt(), key must be at least 256 bits (32 bytes) long.
I have searched but did not find a solution for this error.
In my controller i am setting and array to the cookie's $key.
$this->Auth->setUser($contactData);
$this->Cookie->write('contactData', $contactData);
I have also enabled the component in appController.php.
Any help would be much appreciated.

It means your Security salt in app.php does not have the correct length. Adjust it to match what the error message is suggesting.
'Security' => [
'salt' => env('SECURITY_SALT', <Add your 256 bits (32 bytes) key here>),
],

Related

A misleading "SyntaxError" log + 500

for six months, I learn how to code. While following a Udemy lesson to connect MongoDB and React, two error logs showed up simultaneously. After two days, I did solve the bug. However, I felt a bit misled by my console.
The errors:
1.POST http://localhost:3000/api/new-meetup 500 (Internal Server Error) // 
2.Uncaught (in promise) SyntaxError: Unexpected token I in JSON at position 0
The authorization with MongoDB servers caused the issue since changing the URI popped the same two error logs again.
Since it was on a server-side, the debugger also logged
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
Isn't that a bit missleading logs?.
Nu. 1 >> Problem with the connection.
Nu. 2 >> Problem with the data transferred, usually an escaped character or a spelling error.
It isn't a standard error chain that one can usually see coding with a platform due to a spelling error that crashes many levels.
Is it common to have situations like this with two errors, one of which is not really "the main issue," or am I missing something?.
What worked : changing password and reauthorizing my IP in Momngodb website.
Didn't worked : creating new firewall rule, playing with address, try catch, etc.
the console logged the data so:
enteredMeetupData
{title: '1', image: 'https://media.istockphoto.com/photos/circuit-blue-board-background-copy-space-computer', address: '1', description: '1'}
JSON.stringfy(enteredMeetupData)
{"title":"1","image":"https://media.istockphoto.com/photos/circuit-blue-board-background-copy-space-computer","address":"1","description":"1"}
Which looks OK to me.

ITfoxtec Identity.Saml2.MvcCore -- SAML ERROR Form key length limit 2048 exceeded

I am using ITfoxtec Identity.Saml2.MvcCore for .net core v3.1 for Single sign on using Ping Identity.
SAML ERROR Form key length limit 2048 exceeded. at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ThrowKeyTooLargeException()
at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ParseValuesSlow(ReadOnlySequence1& buffer, KeyValueAccumulator& accumulator, Boolean isFinalBlock) at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ParseFormValues(ReadOnlySequence1& buffer, KeyValueAccumulator& accumulator, Boolean isFinalBlock)
at Microsoft.AspNetCore.WebUtilities.FormPipeReader.ReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.InnerReadFormAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.Features.FormFeature.ReadForm()
at Microsoft.AspNetCore.Http.DefaultHttpRequest.get_Form()
at ITfoxtec.Identity.Saml2.MvcCore.HttpRequestExtensions.ToGenericHttpRequest(HttpRequest request)
at Nbc.Score.Remotes.Web.Controllers.HomeController.AssertionConsumerService()
Failed method ITfoxtec.Identity.Saml2.MvcCore.HttpRequestExtensions.ToGenericHttpRequest
It looks like an form property is to lang, more then 2048 characters. It do not look like it is a value length which is a problem but instead a property length.
How dos the raw response look like?

Error adding field 'field_name'-'field_value' msg=For input string: \"field_Value\"

We are struggling to import certain files into Solr occasionally. It seems like certain documents have weird meta data (values), not sure if it might be from eccentric word processor or something else. See two examples here:
Type: Solarium\Exception\HttpException
Message: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":49},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=3932487729] Error adding field 'brightness_value'='6.18' msg=For input string: \"6.18\"","code":400}}
And
Type: Solarium\Exception\HttpException
Severity: error --> Exception: Solr HTTP error: OK (400)
{"responseHeader":{"status":400,"QTime":72},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.lang.NumberFormatException"],"msg":"ERROR: [doc=16996] Error adding field 'version'='5.3.1' msg=For input string: \"5.3.1\"","code":400}}
How do we prevent these issues? We are not in control of the documents, so need to fix it on the server.
Define the field type explicitly in the schema instead of relying on Solr to create the field type for you - the first document that contains the field will make Solr guess the type of the field, and if later documents doesn't match the same, expected format, you'll get an error like this.
Always define the schema for a collection when using it in production or in an actual application - the schemaless mode is really neat for prototyping and experimenting, but in an actual application you want the types to be well defined.

Authentication fails in databasedotcom

I am trying to adopt databasedotcom gem, but couldn't get beyond the authentication. Here is what I did (after installing databasedotcom gem):
rails c (or irb then require 'databasedotcom')
client=Databasedotcom::Client.new :client_id => 'foo', :client_secret=>'bar'
client.ca_file = '/Users/tjiang/missioncontrol/tmp/ca-bundle.crt'
client.verify_mode = OpenSSL::SSL::VERIFY_PEER
client.authenticate :username=>'myusername', :password=>'mypassword'
All credentials are copy-and-pasted in the process so no mistake there; the certificate was downloaded here: http://certifie.com/ca-bundle/ca-bundle.crt.txt
I tried Ruby 187 and 193 as well as inside and outside Rails, repeatedly, but always got this error message:
Databasedotcom::SalesForceError: authentication failure from /Library/Ruby/Gems/1.8/gems/databasedotcom-1.3.0/lib/databasedotcom/client.rb:112:in `authenticate'
I wonder what I have missed here? Particularly, I am concerned about the Callback URL I used when creating a Remote Access in Salesforce (I tried 'oob', 'http://localhost:3000', and 'https://www.salesforce.com', but none made any difference).
It turns out this is due to a bug in databasedotcom. When you use username and password to authenticate, it puts them into an url query string WITHOUT encoding and POST a request with that url. As a result, the plus sign in my username will be interpreted as a blank space.
Solution: CGI::escape() both your username and password.

CAS AD LDAP 32 error

I am seeing this when I try to login with CAS which is authenticating against AD over LDAP.
SEVERE: Servlet.service() for servlet cas threw exception
javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:
''
]; remaining name '/'
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3092)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3013)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2820)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1829)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1752)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:338)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:257)
at org.springframework.ldap.core.LdapTemplate$3.executeSearch(LdapTemplate.java:231)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:293)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:237)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:588)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:546)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:401)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:421)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:441)
Up to that point I was authenticated by the BindLdapAuthenticationHandler, resolved, it generated a query builder and then threw this.
I think it is failing when it is trying to get attributes back. Why is the remaining name '/'?
Remaining name is a part of a DN that wasn't actually found at a certain level of a DIT. For example when you search cn=johns,ou=marketing,dc=example,dc=com and ou=marketing,dc=example,dc=com exists but cn=johns does not exists inside of ou=marketing then the remaning name would be cn=johns.
'/' does not look like a valid RDN. I would recommend to verify what you pass as a search base. Most likely it's an invalid DN string.
LDAP error code 32 means "no such object", in this case, perhaps the base object of the search did not exist.

Resources