从非Jhipster应用程序向JHipster UAA进行身份验证 [英] Authentication to JHipster UAA from non-jhipster application
问题描述
我用JHipster创建了一个微服务架构.
I used JHipster to create a micro-service architecture.
我正在使用JHipster Registry和JHipster UAA(OAuth2)作为身份验证解决方案.
I'm using JHipster Registry and JHipster UAA (OAuth2) as authentication solution.
现在,我正在寻找一种方法来进行身份验证,并从将在JHipster外部开发的移动应用程序中进行一些API调用.
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.
我尝试通过调用/oauth/token ressource从外部调用UAA服务,但这不起作用.
I tried to call UAA service from outside by calling /oauth/token ressource but it doesn't work.
有什么建议吗?
推荐答案
在微服务体系结构中,您希望通过网关向微服务发出请求,以便它可以对您的微服务(包括UAA)进行负载平衡.像Angular和React客户端在
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, {});
}
请注意,您还需要通过cookie处理身份验证,并确保在每次请求时都发送了XSRF-TOKEN.
Note that you will also need to handle authentication via cookies, and make sure you sent the XSRF-TOKEN with each request.
这篇关于从非Jhipster应用程序向JHipster UAA进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!