簡體   English   中英

Spring RESTful Web服務和Android身份驗證

[英]Spring RESTful Web Service and Android Authentication

我有以下Spring Security配置。

@Override
protected void configure(HttpSecurity http) throws Exception
{
    http
            .authorizeRequests()
                .antMatchers("/admin/**").hasRole("ADMIN")
                .anyRequest().authenticated()
                .and()
            .formLogin()
                .loginPage("/login")
                .permitAll()
                .and()
            .logout()
                .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                .permitAll();
}

它工作正常,但我想擁有使用REST API的Android客戶端應用程序。 當我在Android應用程序中使用API​​時,會將我重定向到Web登錄頁面。 這是理想的行為,但僅在Web應用程序中。

我具有Speditor,Accountant,Driver等角色。除Driver之外,所有其他人都應該能夠登錄Web應用程序。 在android上,我想要單獨登錄,該登錄僅對具有驅動程序角色的用戶進行身份驗證。

問題是我不知道如何分隔這些身份驗證,因此兩個應用程序(Web和Android)可以使用相同的API。 你能給我一些建議嗎?

我的處境相同,但有所不同。 就我而言,我分為3個客戶,如下圖所示:

在此處輸入圖片說明

但是,就我而言,我對三個用戶/密碼具有相同的身份驗證。 我認為有一種方法可以做您嘗試做的事情,但是,您可以開始研究如何與其他客戶端進行身份驗證。

對不起英語,我不是母語人士,所以我正在努力。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM