Greetings to all,
Currently, I am delving into the world of Laravel Passport and Vue.JS (standalone) simultaneously. In my authentication process, I am utilizing the Password Grant Token
.
An issue that has come up is the necessity for keeping the secret_key
hidden at all times.
Within my VueJS application, there is a Login Component
where I need to include the client_secret
as a parameter in order to obtain an access token. However, given that VUEJS operates as a JavaScript framework, there is a likelihood that the client_secret
could be visible in the minified build file.
Hence, my query is whether this situation is deemed normal? Is there a method to shield the client_secret
from prying eyes?
Initially, I did not perceive this as a serious concern since I had implemented CORS
on Laravel, enabling me to specify only the allowedOrigins
. My assumption was that if I could control the allowedOrigins
, then it wouldn't matter if the secret key became known.
Below is a snippet of my code in VueJS:
login(){
this.$validator.validateAll().then((result) => {
if (result) {
var data = {
client_id: 3,
client_secret: 'client-secret key',
grant_type: 'password',
username: this.inputs.email,
password: this.inputs.password
}
this.$http.post("oauth/token", data).then(response => {
this.$auth.setToken(response.body.access_token, response.body.expires_in + Date.now());
bus.$emit('reload');
this.$router.push('/');
})
}
});
}
Any insights or guidance on this matter would be highly valued.
Thank you in advance for your assistance.