Authorization for the nuxt frontend

On another note, it turns out that we don’t need a whole new scheme - we can just replace this:

@Component
export default class Login extends Vue {
  private login(): void {
    this.$auth.loginWith('keycloak')   
  }
}

with this:

export default class Login extends Vue {
  private login(): void {
    this.$auth.loginWith('keycloak', {params: {client_id: process.env.client_id, client_secret: process.env.client_secret} }) 
  }
}

and the nuxt configuration:

auth: {
    strategies: {
      keycloak: {
	_scheme: 'oauth2',
	authorization_endpoint: 'auth/realms/sirixdb/protocol/openid-connect/auth',
	userinfo_endpoint: false,
	access_type: 'offline',
	access_token_endpoint: '/auth/realms/sirixdb/protocol/openid-connect/token',
	response_type: 'code',
	token_type: 'Bearer',
  token_key: 'access_token',
      },
    },
    redirect: {
      login: '/login',
      callback: '/callback',
      home: '/'
    },
  },
  env: {
    client_id: 'sirix',
    client_secret: 'ab00e459-3196-4110-923b-e58d71bd4c88'
  },
  router: {
    middleware: ['auth']
  },
  proxy: {
    '/auth/': {
      target: 'http://localhost:8080',
      pathRewrite: {'^/api/': ''}
    }
  }

And it seems to work, until I get a
We're sorry... An error occurred, please login again through your application.
from the /auth/realms/sirixdb/login-actions/authenticate endpoint. I’m stuck on that.

1 Like