2013-03-22 2 views
1

설정 :HTTP 상태 403가 계속

  • 글래스 피쉬 3.1.1
  • JSF 2.1
  • jdbcRealm PostgreSQL을

에 유효한 사용자를 입력 한 후 로그인 양식에 대한 자격 증명 로그인되어 다음 페이지로 리디렉션됩니다. 하지만 해당 페이지를 나가서 허용 된 URL 패턴에있는 다른 페이지로 이동하면 "HTTP Status 403 - 요청한 리소스에 대한 액세스가 거부되었습니다."라는 메시지가 나타납니다. 그 후 나는 webapp의 어떤 사이트도 더 이상 방문 할 수 없다.

로그인은 glassfish의 server-config/security에서 Standard-Realm을 내 영역으로 설정 한 경우에만 작동합니다!

Warnung: Keine Principals zugeordnet zu Rolle [USER]. 
(Warning: No principals mapped to role [USER]) 

내가 크롬 디버거와 JSESSIONID를 제거하면, 내가 다시 로그인 할 수 있습니다

나는 배포시 서버 로그에 하나의 경고가. 허용 된 웹 사이트 또는 뭔가를 방문한 후 서버 측에서 세션이 파괴 된 것처럼 보입니까?!

몇 가지 관련 출처를 첨부했습니다. 나는

web.xml을

<login-config> 
    <auth-method>FORM</auth-method> 
    <realm-name>jdbcRealm</realm-name> 
    <form-login-config> 
     <form-login-page>/faces/login.xhtml</form-login-page> 
     <form-error-page>/faces/loginError.xhtml</form-error-page> 
    </form-login-config> 
</login-config> 

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>User</web-resource-name> 
     <url-pattern>/faces/user/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>POST</http-method> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>ADMIN</role-name> 
    </auth-constraint> 
</security-constraint> 

글래스 피쉬 - 웹 응용 프로그램 ...는 로그인 메커니즘이 작동하고 예외가 없기 때문에, 영역과 등 아무 상관이 없다 생각합니다. XML (수동으로 추가)

<glassfish-web-app> 
<security-role-mapping> 
    <role-name>USER</role-name> 
    <group-name>USER</group-name> 
</security-role-mapping> 
</glassfish-web-app> 

login.xhtml

,
<h:form> 
<h:outputLabel for="usernameInput"> 
    Username: 
</h:outputLabel> 
<h:inputText id="usernameInput" value="#{authBackingBean.username}" 
      required="true" /> 
<br /> 
<h:outputLabel for="passwordInput"> 
    Password: 
</h:outputLabel> 
<h:inputSecret id="passwordInput" value="#{authBackingBean.password}" 
       required="true" /> 
<br /> 
<h:commandButton value="Login" 
       action="#{authBackingBean.login}" /> 

AuthBackingBean P.S

@Stateless 
@Named 
public class AuthBackingBean { 

    private String username; 
    private String password; 

    public String getUsername() { 
     return this.username; 
    } 

    public void setUsername(String username) { 
     this.username = username; 
    } 

    public String getPassword() { 
     return this.password; 
    } 

    public void setPassword(String password) { 
     this.password = password; 
    } 

    public String login() { 
     FacesContext context = FacesContext.getCurrentInstance(); 
     HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); 
     try { 
      request.login(this.username, this.password); 
     } catch (ServletException e) { 
      context.addMessage(null, new FacesMessage("Login failed.")); 
      return "loginError"; 
     } 
     return "user/index"; 
    } 

    public void logout() { 
     FacesContext context = FacesContext.getCurrentInstance(); 
     HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); 
     try { 
      request.logout(); 
     } catch (ServletException e) { 
      context.addMessage(null, new FacesMessage("Logout failed.")); 
     } 
    } 
} 

: 그것은 많은 논리적 오류, 오타 및 복사/붙여 넣기 오류를 포함하고 있기 때문에 나는 오라클의 F 정말 실망이 *** 문서를 에드. 체계적이지 않고 읽기가 어렵고 과부하입니다. 표준 (

내가 "표준-교장 안녕히 Rollenzuordnung"을 활성화 :

답변

6

이 테스트의 시간 후, 재미 있고 나는 일분을 게시 한 후 답을 발견이 질문을 작성 (미안하지만 그건 말할 수했다) -Principal to Rolemapping)을 server-config/security에 추가하면 작동합니다.

+0

모든 것이 완벽하게 작동했을 때 갑자기 403 오류가 발생했습니다. 누군가 "rolemapping에 대한 표준 원칙"이 무엇인지 생각하는 사람이 있습니까? 안전 해요? 글래스 피쉬는 내 경험으로 인해 끔찍한 것 같습니다. 너무 불안정하고 많은 질문이 ... – wired00

1

Roles, Principals and Role Mapping에 대한이 설명서를 읽은 후 "표준 - 프린시 펄 - 역할 매핑"을 사용하는 대신 역할 매핑을 사용하여 glassfish-web.xml (WEB-INF) 설명자를 정의 할 수 있음을 알았습니다.

예 : 만약 내가 제대로 이해하고

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD 
GlassFish Application Server 3.1 Servlet 3.0//EN" 
     "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd" 
     > 

<glassfish-web-app> 
    <context-root>/istop</context-root> 
    <security-role-mapping> 
     <role-name>described-role</role-name> 
     <principal-name>user-that-should-have-this-role</principal-name> 
     <group-name>equivalent-role-in-db</group-name> 
    </security-role-mapping> 
</glassfish-web-app> 

, described-role 중 하나 web.xml에 정의가 마지막으로 <role-name /> 또는

@DeclaredRoles를 사용 <role-name /> 경기에서 사용 있는지 확인 어떤 옵션 "에 STANDAR - 교장 역할 맵핑 "은 Role이 응용 프로그램에 정의 된 영역 매핑 Goup Name Column과 일치 할 것으로 기대하므로 데이터베이스의 모든 사용자는 정의 된 역할 중 하나와 일치하는 역할을 가져야합니다.