移动应用中的Jhipster登录/身份验证 [英] Jhipster login / authentication in mobile app
问题描述
如何从 jhipster 获取会话cookie 和 CSRF令牌,然后在通过移动应用程序调用API时使用它们. 我正在使用HTTP会话身份验证.
How to get a session cookie and the CSRF token from jhipster then use them in your calls to the API from mobile app. I am using HTTP session authentication.
JHipster配置,在根文件夹中生成的 .yo-rc.json文件
JHipster configuration, a .yo-rc.json file generated in the root folder
{
"generator-jhipster": {
"jhipsterVersion": "3.0.0",
"baseName": "vconnect",
"packageName": "com.zenfact.vconnect",
"packageFolder": "com/zenfact/vconnect",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"enableSocialSignIn": false,
"rememberMeKey": "559bbe3167552d040ba24d16506d389a7ba851c3",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"zh-cn",
"fr",
"hi",
"ja"
]
}
}
推荐答案
我没有任何移动体验,但众所周知,使用cookie难以移动.我建议改用jhipster的Oauth2选项.然后,您只需要获取访问令牌并将标头"Authorization:Bearer"添加到您的api调用中即可.
I don't have any mobile experience but cookies are known to be difficult with mobile. I'd recommend using jhipster's Oauth2 option instead. Then you just need to get an access token and add the header "Authorization: Bearer " to your api calls.
这篇关于移动应用中的Jhipster登录/身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!