Authentication to JHipster UAA from non-jhipster application

99封情书 提交于 2019-12-10 11:34:22

问题


I used JHipster to create a micro-service architecture.

I'm using JHipster Registry and JHipster UAA (OAuth2) as authentication solution.

Now I'm looking for a way to authenticate and make some API calls from a mobile application that would be developed outside of JHipster.

I tried to call UAA service from outside by calling /oauth/token ressource but it doesn't work.

Any advices?


回答1:


In a microservice architecture, you want to make requests to microservices through the gateway so it can load-balance to your microservices (including the UAA). Use the login route through the gateway (/auth/login), like the Angular and React clients do in auth-jwt.service.ts:

login(credentials): Observable<any> {
    const data = {
        username: credentials.username,
        password: credentials.password,
        rememberMe: credentials.rememberMe
    };
    return this.http.post(SERVER_API_URL + 'auth/login', data, {});
}

Note that you will also need to handle authentication via cookies, and make sure you sent the XSRF-TOKEN with each request.



来源:https://stackoverflow.com/questions/52264350/authentication-to-jhipster-uaa-from-non-jhipster-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!