Ich versuche, JDBC Realm Form-Authentifizierung zu verwenden, um Sicherheit für meine Anwendung festzulegen, aber es funktioniert nicht. Wenn ich versuche mich anzumelden, lädt die Seite einfach neu. Ich bekomme keine Fehler, es gibt nichts in den Logs.JDBC Realm Formular-Authentifizierung
Hier web.xml
<error-page>
<error-code>403</error-code>
<location>/faces/views/errors/403.xhtml</location>
</error-page>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>jdbcRealm</realm-name>
<form-login-config>
<form-login-page>/faces/views/account/login.xhtml</form-login-page>
<form-error-page>/faces/views/account/loginerror.xhtml</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin user</web-resource-name>
<url-pattern>/faces/views/admin/*</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>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin user</web-resource-name>
<url-pattern>/faces/views/users/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
<role-name>guest</role-name>
</auth-constraint>
</security-constraint>
Hier Glasfischen-web.xml
<security-role-mapping>
<role-name>admin</role-name>
<group-name>admin</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>guest</role-name>
<group-name>guest</group-name>
</security-role-mapping>
Formular
<form method="POST" action="j_security_check">
Username: <input type="text" name="j_username" />
Password: <input type="password" name="j_password" />
<input type="submit" value="Login" />
<input type="reset" value="Reset" />
</form>
- JAAS Kontext: jdbcRealm
- JNDI: jdbc/kyrspr
- Benutzertabelle: USER
- Spalte Benutzername: NAME
- Passwort Säule: PASSWORT
- Gruppe Tabelle: USERS_GROUP
- Gruppenname Spalte: GROUP_NAME
- Kennwortverschlüsselungsalgorithmus: MD5
und Datenbanktabellen
CREATE TABLE user (
ADDRESS VARCHAR(255),
EMAIL VARCHAR(255),
IMAGE VARCHAR(255),
NAME VARCHAR(255) PRIMARY KEY NOT NULL,
PASSWORD VARCHAR(255),
RATING DOUBLE,
SPECIALLITY_ID BIGINT(20)); CREATE UNIQUE INDEX user_NAME_uindex ON user (NAME);
CREATE TABLE users_group
(
USER_ID VARCHAR(255),
GROUP_NAME VARCHAR(15) NOT NULL,
group_id BIGINT(20) PRIMARY KEY NOT NULL,
CONSTRAINT users_group_user_NAME_fk FOREIGN KEY (USER_ID) REFERENCES user (NAME)
);
CREATE UNIQUE INDEX users_group_group_id_uindex ON users_group (group_id);
CREATE INDEX users_group_user_NAME_fk ON users_group (USER_ID);