我正在使用Auth0来处理我的网络应用程序中的身份验证.我正在使用ASP.NET Core v1.0.0和Angular 2 rc5,我对身份验证/安全性一般不太了解.
在ASP.NET Core Web Api的Auth0文档中, JWT算法有两种选择:RS256和HS256.这可能是一个愚蠢的问题但是:
RS256和HS256有什么区别?有哪些用例(如果适用)?
我生成了一个JTW令牌,并且有一些我很清楚的声明,但是kid在标题中有一个声明.有谁知道这意味着什么?
我使用auth0.com生成令牌
我正在使用制作REST API Jersey。我正在使用java-jwt(https://github.com/auth0/java-jwt)进行令牌生成工作。请检查以下代码。
UserJSONInfo -REST方法类
@Path ("/user_info")
public class UserInfoJSONService
{
@POST
@Path("/authenticateUser")
@Produces(MediaType.APPLICATION_JSON)
public Response authenticateUser(Credentials credentials)
{
UserInfoService service = new UserInfoService();
try{
UserInfo authenticateUser = service.authenticateUser(credentials.getUserName(), credentials.getPassword());
String generateToken = service.generateToken(AuthKey.authorizationSecret);
Authentication auth = new Authentication();
auth.setIdUser(authenticateUser.getIduser());
auth.setToken(generateToken);
return Response.status(Response.Status.OK).entity(auth).build();
//return authenticateUser;
}
catch(IndexOutOfBoundsException e)
{
throw new WebApplicationException(Response.Status.BAD_REQUEST);
} catch (JWTCreationException ex) {
throw new WebApplicationException(Response.Status.UNAUTHORIZED);
} catch (UnsupportedEncodingException ex) {
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
}
Run Code Online (Sandbox Code Playgroud)
UserInfoService-服务层
public class …Run Code Online (Sandbox Code Playgroud)