Wildfly 8에서 실행되는 Java-Webapp가 있습니다. resteasy Annotations로 편안한 웹 서비스를 확보하려고합니다. 명령 줄 툴 컬을 사용하여 나머지 API를 테스트합니다.Wildfly 8 기본 인증
기본 인증 설정이 작동하는 것 같습니다. 주석이있는 웹 서비스에 대한 HTTP 요청은 "@PermitAll"이 정상적으로 작동합니다. Curl이 말합니다 :
~ % curl -v http://localhost:8080/ItilityServer-web/rest/account
> GET /ItilityServer-web/rest/account HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: keep-alive
< X-Powered-By: Undertow/1
< Server: WildFly/8
< Content-Length: 0
< Date: Wed, 28 Jan 2015 10:47:11 GMT
<
* Connection #0 to host localhost left intact
유효한 사용자 이름과 암호가 포함 된 HTTP 요청은 승인되지 않은 상태 코드 401과 함께 거부됩니다. 제이보스는 오류 타의 추종을 불허하는 암호를 기록합니다
2015-01-28 11:42:43,565 TRACE [org.jboss.security] (default task-5) PBOX000263: Executing query SELECT a.password FROM Account a WHERE a.name = ? with username hans
2015-01-28 11:42:43,566 DEBUG [org.jboss.security] (default task-5) PBOX000283: Bad password for username hans
을하지만 이것은 사실이 아니다. 해독 된 인증 세부 정보 "aGFuczpoZWxtaWhlbG1paGVsbWk ="는 hans : helmihelmihelmi이며이 사용자 이름과 암호는 내 db에 저장됩니다. security-domain과 같은 jpql-queries는 unsername "hans"와 그의 암호 "helmihelmihelmi"를 사용합니다. 여기
내 설정 :
web.xml을
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<context-param>
<param-name>resteasy.role.based.security</param-name>
<param-value>true</param-value>
</context-param>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Application</realm-name>
</login-config>
<security-role>
<role-name>store</role-name>
</security-role>
</web-app>
(I 보안 영역이 무엇인지 모르는, 그래서 난 그냥 로그인 - 구성 태그에이 속성을 왼쪽)
독립형 폴더의 내 보안 도메인
<security-domain name="DBLogin" cache-type="default">
<authentication>
<login-module code="Database" flag="required">
<module-option name="dsJndiName" value="java:jboss/datasources/ExampleDS"/>
<module-option name="principalsQuery" value="SELECT a.password FROM Account a WHERE a.name = ?"/>
<module-option name="rolesQuery" value="SELECT a.userRole FROM Account a WHERE a.name = ?"/>
<module-option name="hashAlgorithm" value="SHA-256"/>
<module-option name="hashEncoding" value="Base64"/>
<module-option name="hashCharset" value="UTF-8"/>
<module-option name="unauthenticatedIdentity" value="guest"/>
</login-module>
</authentication>
</security-domain>
안정적인 웹 서비스
012 심지어 문제를 모르기 때문에 3,516,@GET
@RolesAllowed(AuthRole.STORE)
@Produces(MediaType.APPLICATION_JSON)
public Response getAccountByName() {
Response.ResponseBuilder builder = Response.ok();
return builder.build();
}
및 import.xml는 해결책을 찾기 위해 방법을 알고하지 마십시오
insert into Account(id, name, email, password, user_role) values (0, 'hans', '[email protected]', 'helmihelmihelmi', 'store')
insert into Store(id, name, zipcode, street, housenumber, town, account_id) values(0, 'Edeka', 72622, 'stephanstraße', 10, 'Reudern', 0);
시작
에 사용자를 만들 수 있습니다. 누군가가 도울 수 있기를 바랍니다.
그게 해결책 이었어! 고마워. – Helmosch
IMHO는 원시 또는 안전하지 않은 해시 된 암호를 저장하는 것은 요즈음 범죄적인 태만으로 간주됩니다. –