PCF Config server Authentication issues - spring-boot

I am following the below to set up a config server in PCF and access the application in PCF.
https://github.com/pcf-guides/gs-configuration-server
I have added the config server from the PCF marketplace and it is bind with the app.
The config server is pointed to the following Git repository:
https://github.com/pcf-guides/configuration-server-config-repo.git
The VCAP_SERVICES is like below :
"p-config-server": [
{
"binding_name": null,
"credentials": {
"access_token_uri": "https://p-spring-cloud-
services.uaa.run.pivotal.io/oauth/token",
"client_id": "p-config-server-d837bb39-4cf1-47ce-994b-03257852a7f6",
"client_secret": "XXsWzX6IhKME",
"uri": "https://config-9f0e115f-dbb0-42e8-981a-e70e2cd62570.cfapps.io"
},
"instance_name": "sconfigserver",
"label": "p-config-server",
"name": "sconfigserver",
"plan": "trial",
"provider": null,
"syslog_drain_url": null,
"tags": [
"configuration",
"spring-cloud"
Whenever I am trying to access the application authentication error is coming :
Full authentication is required to access this resource.
I dont have any security configuration in the application.

In your application.properties file, you should add the following
management.security.enabled=false
This will disable security altogether.

I tried this in my main application class and worked fine for me
#SpringBootApplication(exclude = {SecurityAutoConfiguration.class , ManagementWebSecurityAutoConfiguration.class})

Related

Strapi deployment to Heroku

I am totally new on Strapi and Heroku. I am trying to deploy my app that is working well locally to Heroku but I am getting the following error:
2020-06-15T09:56:29.114780+00:00 app[web.1]: [2020-06-15T09:56:29.114Z] error Impossible to register the 'menus.menus' model.
2020-06-15T09:56:29.115672+00:00 app[web.1]: [2020-06-15T09:56:29.115Z] error TimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
At the beginning I thought it was a problem connecting to the database, but in my local environment it work perfectly and connect with no issues.
I even upgraded my database to a paid version in case the connection is timing out.
I also follow some answers I found only about modifying my config/environment/production/database.json as follow:
{
"defaultConnection": "default",
"connections": {
"default": {
"connector": "bookshelf",
"settings": {
"client": "postgres",
"host": "***.compute-1.amazonaws.com",
"port": "5432",
"database": "***",
"username": "***",
"password": "***",
"ssl": { "rejectUnauthorized": false }
},
"options": {
"debug": false,
"acquireConnectionTimeout": 100000,
"pool": {
"min": 0,
"max": 10,
"createTimeoutMillis": 30000,
"acquireTimeoutMillis": 600000,
"idleTimeoutMillis": 20000,
"reapIntervalMillis": 20000,
"createRetryIntervalMillis": 200
}
}
}
}
}
Any other idea of what can it be?
When I run the develop locally I got a warn (but even this the app run anyway after):
[2020-06-15T10:36:41.261Z] warn The bootstrap function is taking unusually long to execute (3500 miliseconds).
[2020-06-15T10:36:41.261Z] warn Make sure you call it?
[2020-06-15T10:36:42.476Z] warn The bootstrap function is taking unusually long to execute (3500 miliseconds).
[2020-06-15T10:36:42.476Z] warn Make sure you call it?
One simple first step option is to launch a strapi quickstart application on heroku. You can find this link here.. https://github.com/strapi/strapi
Relaunching with this method will provide you with a working, secure instance to begin development on.
Also note that heroku deploys strapi to production, so that you are not able to use the content-types editor, so it is recommended that you develop locally & test your app and use the heroku cli to update your deployment.

how to proxy API requests? (Angular-CLI)

I'm working on Java project with Spring-4 and Angular-5. Session is generated on spring side.
So, I'm not able to generate this session from angular Service. It's working on Postman and I'm able to get response in PostMan.
But It's not working with Angular post method call.
So, I thought that it's may be a issue of Proxy. (Corrent me If i'm wrong).
So, My local Url is :- http://localhost:8080/MacromWeb/ws/login
So, How Can I make a proxy.conf.json file?
So for that I have added this code to my package.json file,
"start": "ng serve --proxy-config proxy.conf.json",
I have created a new file called proxy.conf.json.
And Put this code in it.
{
"/": {
"target": "http://localhost:8080/MacromWeb/ws",
"secure": false
}
}
Then I tried with ng serve and npm start both.
Postman Screenshot.
You can achieve this through proxy, You need to provide proper values in the proxy config.
/* should work too, but if MacromWeb is common in API URLs, then instead of / provide /MacromWeb/*
proxy.conf.json looks something like this,
{
"/MacromWeb/*": {
"target": {
"host": "localhost",
"protocol": "http:",
"port": 8080
},
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
Hope it helps.
Say we have a server running on http://localhost:3000 and we want all calls to http://localhost:4200/api to go to that server.
In our proxy.conf.json file, we add the following content
{
"/api": {
"target": "http://localhost:3000",
"secure": false,
"pathRewrite": {
"^/api": ""
}
}
}
More on this: here

Multiple Service Definition in Config File Not Working Consul

I have been trying to add multiple service through configuration in consul.
But Consul UI is throwing error at startup of the agent itself.
The error is:-
$consul.exe agent --dev
Starting Consul agent...
panic: runtime error: invalid memory address or nil pointer dereference
github.com/hashicorp/consul/agent.(*Agent).loadServices(0xc0421268c0,
0xc04223aa80, 0xc042254a00, 0x0)
/gopath/src/github.com/hashicorp/consul/agent/agent.go:2097
github.com/hashicorp/consul/agent.(*Agent).Start()
/gopath/src/github.com/hashicorp/consul/agent/agent.go:326
github.com/hashicorp/consul/command.(*AgentCommand).run()
/gopath/src/github.com/hashicorp/consul/command/agent.go:704
github.com/hashicorp/consul/command.(*AgentCommand).Run()
/gopath/src/github.com/hashicorp/consul/command/agent.go:653
Config file is:-
{
"Services": [{
"id": "somename",
"name": "nameofthissevice",
"service": "myservice",
"address": "127.0.0.1",
"port": 62133,
"enableTagOverride": false,
"tags" : ["service1"]
},
{
"id": "somename1",
"name": "nameofthissevice",
"service": "myservice2",
"address": "127.0.0.1",
"port": 64921,
"enableTagOverride": false,
"tags" : ["service2"]
}]
}
I am using Win 7 platform.
Could any one suggest some ideas in it.
Thx
The configuration file is not loaded, so the problem is not in the file, in order to load the configuration file you should add another flag for loading the configuration, otherwise consul will start with default configuration.
Looks like a faulty binary or incompatible version.
Your windows7 is a 32 bit arch or 64?
And which exec version of consul have you downloaded ?

Querying remote registry service on machine <IP Address> resulted in exception: Unable to change open service manager

My cluster Config file as follows
`
{
"name": "SampleCluster",
"clusterConfigurationVersion": "1.0.0",
"apiVersion": "01-2017",
"nodes":
[
{
"nodeName": "vm0",
"iPAddress": "here is my VPS ip",
"nodeTypeRef": "NodeType0",
"faultDomain": "fd:/dc1/r0",
"upgradeDomain": "UD0"
},
{
"nodeName": "vm1",
"iPAddress": "here is my another VPS ip",
"nodeTypeRef": "NodeType0",
"faultDomain": "fd:/dc1/r1",
"upgradeDomain": "UD1"
},
{
"nodeName": "vm2",
"iPAddress": "here is my another VPS ip",
"nodeTypeRef": "NodeType0",
"faultDomain": "fd:/dc1/r2",
"upgradeDomain": "UD2"
}
],
"properties": {
"reliabilityLevel": "Bronze",
"diagnosticsStore":
{
"metadata": "Please replace the diagnostics file share with an actual file share accessible from all cluster machines.",
"dataDeletionAgeInDays": "7",
"storeType": "FileShare",
"IsEncrypted": "false",
"connectionstring": "c:\\ProgramData\\SF\\DiagnosticsStore"
},
"nodeTypes": [
{
"name": "NodeType0",
"clientConnectionEndpointPort": "19000",
"clusterConnectionEndpointPort": "19001",
"leaseDriverEndpointPort": "19002",
"serviceConnectionEndpointPort": "19003",
"httpGatewayEndpointPort": "19080",
"reverseProxyEndpointPort": "19081",
"applicationPorts": {
"startPort": "20001",
"endPort": "20031"
},
"isPrimary": true
}
],
"fabricSettings": [
{
"name": "Setup",
"parameters": [
{
"name": "FabricDataRoot",
"value": "C:\\ProgramData\\SF"
},
{
"name": "FabricLogRoot",
"value": "C:\\ProgramData\\SF\\Log"
}
]
}
]
}
}
It is almost identical to standalone service fabric download demo file for untrusted cluster except my VPS ip. I enabled remote registry service.I ran the
\TestConfiguration.ps1 -ClusterConfigFilePath \ClusterConfig.Unsecure.MultiMachine.json but i got the following error.
Unable to change open service manager handle because 5
Unable to query service configuration because System.InvalidOperationException: Unable to change open service manager ha
ndle because 5
at System.Fabric.FabricDeployer.FabricDeployerServiceController.GetServiceStartupType(String machineName, String serv
iceName)
Querying remote registry service on machine <IP Address> resulted in exception: Unable to change open service manager
handle because 5.
Unable to change open service manager handle because 5
Unable to query service configuration because System.InvalidOperationException: Unable to change open service manager ha
ndle because 5
at System.Fabric.FabricDeployer.FabricDeployerServiceController.GetServiceStartupType(String machineName, String serv
iceName)
Querying remote registry service on machine <Another IP Address> resulted in exception: Unable to change open service manager
handle because 5.
Best Practices Analyzer determined environment has an issue. Please see additional BPA log output in DeploymentTraces
LocalAdminPrivilege : True
IsJsonValid : True
IsCabValid :
RequiredPortsOpen : True
RemoteRegistryAvailable : False
FirewallAvailable :
RpcCheckPassed :
NoConflictingInstallations :
FabricInstallable :
DataDrivesAvailable :
Passed : False
Test Config failed with exception: System.InvalidOperationException: Best Practices Analyzer determined environment has
an issue. Please see additional BPA log output in DeploymentTraces folder.
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
I don't understand the problem.VPSs are not locally connected. All are public IP.I don't know, this may b an issue. how do I make virtual LAN among these VPS?Can anyone give me some direction about this error?Anyone helps me is greatly appreciated.
Edit: I used VM term insted of VPS.
Finally I make this working. Actually all the nodes are in a network, i thought it wasn't. I enable file sharing. I try to access the shared file from the node where I ran configuration test to the all other nodes. I have to give the credentials of logins. And then it works like a charm.

Play framework app heroku configuration error: Key 'application.conf' may not be followed by token: 'application.prod.conf'

I built an app based on template play-silhouette-seed-slick. template link
I got a configuration error caused by com.typesafe.config.ConfigException$Parse after deploying the app to heroku.
"Configuration error: Configuration error[ # file:/app/target/universal/stage/conf/: 2: Key 'application.conf' may not be followed by token: 'application.prod.conf' (if you intended 'application.prod.conf' to be part of a key or string value, try enclosing the key or value in double quotes)]"
The Procfile
web: target/universal/stage/bin/panobike-plus-server -Dhttp.port=${PORT} -Dconfig.resource=${PLAY_CONF_FILE}
And app.json
{
"name": "play-silhouette-slick-seed",
"description": "Seed project to show how Silhouette can be implemented into a Play Framework application with database access using Slick 3.",
"keywords": [
"Play",
"Silhouette",
"Slick"
],
"website": "https://github.com/sbrunk/play-silhouette-slick-seed",
"repository": "https://github.com/sbrunk/play-silhouette-slick-seed",
"success_url": "/",
"env": {
"BUILDPACK_URL": "https://github.com/heroku/heroku-buildpack-scala.git",
"PLAY_CONF_FILE": "application.prod.conf",
"PLAY_APP_SECRET": "changeme",
"FACEBOOK_CLIENT_ID": "",
"FACEBOOK_CLIENT_SECRET": "",
"GOOGLE_CLIENT_ID": "",
"GOOGLE_CLIENT_SECRET": "",
"TWITTER_CONSUMER_KEY": "",
"TWITTER_CONSUMER_SECRET": ""
}
}
In my production config "application.prod.conf", there is no such key "application.conf".
What does this error message mean?
Thank you
It was a stupid question.
I did not call the https://api.heroku.com/app-setups endpoint to setup the app.json enabled application on Heroku.
I had the same error. That was due to lack of PLAY_CONF_FILE env variable. To fix this error you need to open Heroku web page -> Settings -> click on Config Vars button and set new PLAY_CONF_FILE variable. For example application.staging.conf

Resources