데이터베이스 메소드에 접속하기 위해 AngularJS 클라이언트 애플리케이션 및 WebApi가 있습니다. 사용자 인증을 위해 IdentityServer3
이 있습니다. localhost:5005/core/connect/authorize?client_id=ClientA&redirect_uri=http%3A%2F%2Flocalhost%3A30005%2Fcallback&response_type=code%20id_token&scope=openid&state=94bbc0299da444468bb9cc21e5277cf1&nonce=873ea5f66fe0468faa9a362bf1a50e46"
WebAPI 컨트롤러 메소드를 사용하여 로그인하기 위해 IdentityServer 인증 메소드를 호출하는 방법
- IdentityServer 로그인 할 수
localhost:5000/Auth/Login
- 앱 각도 : 나는 WebAPI 로그인 컨트롤러 메소드를 통해 사용자를 인증 할 수있는 방법을
localhost:30005
,451,515,
public class LoginController : ApiController
{
[HttpGet]
public string Login(UserInfo user)
{
// How to implement the logic
}
}
모델 :
public class UserInfo
{
public string UserId { get; set; }
public string Password { get; set; }
}
WebAPI 시작
public class Startup
{
public void Configuration(IAppBuilder app)
{
JwtSecurityTokenHandler.InboundClaimTypeMap.Clear();
app.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "localhost:5005",
RequiredScopes = new[] { "idmgr" } });
app.UseWebApi(WebApiConfig.Register());
}
}
친절 방법 WebAPI에 로그인 방법을 구성하는 방법 도와주세요.
예 ... 그것의'https' 버전 만 ... 그리고'AngularJs 1.xx'를 사용하고 있습니다. 제 질문은 이것을 사용하여'[Authorize]'WebAPI 메소드를 호출하는 방법입니다. WebAPI에'OWIN' Auth를 설정해야합니까? 그렇다면 IdentityServer 토큰을 무기명 토큰으로 받아 들일 것입니까? –
예 owin을 구성하고 IAppBuilder 메서드에 "UseIdentityServerBearerTokenAuthentication"이라는 확장 메서드가 있어야합니다.이 메서드는 필요한 범위와 권한 (서버 URL)과 함께 사용됩니다. response_type을 "token"으로 지정하고 응답 토큰 유형을 bearer 또는 pop 유형으로 지정할 수있는 경우 IdentityServer에서 authtoken을 제공 할 수 있습니다. –
@ B.Balamanigandan은 JWT 토큰을 만들 때 코드를 한눈에 추가 할 수 있습니까? –