I have an URL that requires me digest auth using username and password.
curl -k --digest -u user:password https://api.uni5.net/cliente
But have no idea how to use Digest in get Request for Java application.
I'm searching for a simple way, cuz actually we dont use Java in our development, but now we need to use it inside the server.
Thanks for help!
Related
I'm looking for a way to implement the following mTLS authenticated request in Java:
PFX=x509.pfx
curl --location --request POST 'https://example.com/' \
--cert-type p12 \
--cert "$PFX:mySecretPassword"
I'm using a x509 pfx file encrypted with a password.
For server side, choose framework like Spring.
Check Spring Security docs for more.
Here is intro https://www.baeldung.com/x-509-authentication-in-spring-security
To implement client only try okHttp,
that is usually troublesome to use custom certificate in client, e.g. Use a certificate in an okhttp request with android
So state what exactly you want, and raise better question.
As an advise, try to use standard/default configuration as much as possible.
https://www.baeldung.com/spring-boot-https-self-signed-certificate
I'm trying to find some API (for example java, but could be some other) how to get published docker image names / tags from google cloud platform registry. I found how to do this using gcloud console commands:
gcloud container images list-tags gcr.io/[GCP_REPOSITORY_NAME]
And it basically gave what I want, but it is console and I need this data get programmatically on back-end side. Any ideas guys? Thanks in advance.
Currently there is no REST API for the Google Container Registry product but you can use the Registry name as an URL and run an HTTP request within your Java code against it:
curl -u "oauth2accesstoken:yourAccessToken" https://gcr.io/v2/yourProject/yourImage/tags/list
You can get the accessToken with the command gcloud auth print-access-token. The recommend approach is that it belongs to a serviceAccount.
Although I am not sure if the Docker Registry HTTP API V2 is fully compatible with Google Container Registry, this specific method has worked for me.
I have a simple nativeScript application (ng-groceries ), which I created by following up a tutorial. And Now I have also managed to get Jhipster Microservice and Jhipster Microservice Gateway App is up and running. I am trying to login from nativeScript app to Jhipster app. I have searched many places, tried to understand generated code , but not able to figure out the solution. I know this has to do something with JWT token, Can someone please point me in the correct direction, or give an approach to the solution. It will be great help.
OK.
I have tried following things:
Tried calling http://169.254.86.103:8080/FITHSERVICEMONGO/api/authenticate/" in loginService.ts. but can not see any thing on the console of Jhipster service server.
169.254.86.103 is the external IP given when I start Jhipster service app by mvnw.
FITHSERVICEMONGO is the name of my service app.I had also tried removing this from url.When I login from gateway app from UI,the request that gets is http://169.254.86.103:8080/api/authenticate.I had tried with this too. same ,nothing on service console nor on gateway app console. both are started by mvnw
To check of this IP is really accessible from my emulator . I tried accessing //169.254.86.103:8080/#/ from emulator browser. It works.
The gateway application works in browser. where as //localhost:8080/#/. was not working.
I was expecting that, when I send an authenticate request with params as username and password. I will get a JWT token in return and that token I will pass with every subsequent request.
the syntax of my code is :
http.post(
//BackendService.apiUrl + "oauth/token",
"BackendService.apiUrl" + "/FITHSERVICEMONGO/api/authenticate/",
JSON.stringify({
username: user.email,
password: user.password
}),
{ Content-Type: "application/json"}
)
To authenticate a third party front-end app with JHipster's back-end you can do the same thing as the angular front-end, calling /api/authenticate and using passing the received the jwt token in api headers. Swagger UI is your friend on order to achieve this.
Here is how to retrieve the JWT token using curl:
curl -X POST localhost:8080/api/authenticate -d '{"password":"admin","username":"admin"}' -H 'Content-Type: application/json'
Sample authenticated request:
curl -X POST localhost:8080/api/users -H 'Authorization: Bearer YOURTOKENHERE'
I am having a hard time with the OpenShift client tools on Ubuntu. It keeps asking for a password which I am now confused about. Issuing rhc apps command displays the following message : Please sign in to start a new session to openshift.redhat.com.
I entered my openshift account password but got a message that it was invalid. What password is required here ??
Use the -l param to be sure you are using your account:
rhc domain show -l yourmail#mail.my
Use the same credentials that used in the web site.
BTW, If you use only an OpenShift account, the setup will configure the access with certificate and you won't need use password from command line.
rhc setup
It should use the same username/password that you log into the web console with.
I am currently accepting the parameters login and password in my servlet, but logs are storing this info when using wget (as long as it is GET method, and apache is in the middle)
Instead of this I want to enhance my servlet's authentication accepting:
wget --http-user=login --http-password=password http://myhost/myServlet
How can I read, in my servlet, the server side, the login and the password user is sending, in java code?
Can you not persuade your servlet clients to use POST instead of GET? wget has --post-data and --post-file options which might do what you need it.
wget's --http-user and --http-password options cause it to send HTTP Basic authentication. They are normally used for simple access control enforced by the web server itself, typically mediated by a .htaccess file; you'll have to consult your servlet framework documentation to find out whether that is available to you.