웹 서비스 보안 탐색
기본 인증, 상호 인증 또는 WS-보안을 사용하여 보안을 적용합니다.
기본 인증
WSDL 문서 또는 SOAP 메시지 게시에 대한 각 요청에 대해 기본 인증을 적용하려면 속성을 glide.basicauth.requiredtrue로 설정할 수 있습니다. 이렇게 하면 각 WSDL 또는 SOAP 요청에 기본 인증 프로토콜에 지정된 대로 "Authorization" 헤더가 포함되어야 합니다. 요청이 비대화형이므로 요청 중에 항상 Authorization 헤더가 필요합니다.
필수 여부에 관계없이 기본 인증 정보를 제공하면 웹 서비스 호출의 결과로 작성되거나 업데이트된 데이터가 기본 인증 자격 증명에 제공된 사용자를 대신하여 수행된다는 추가 이점이 있습니다. 예를 들어, 인시던트 기록을 만들 때 저널 필드에는 기본 게스트 사용자 대신 기본 인증 사용자의 사용자 ID가 있습니다.
권한 부여 헤더가 대문자 사용 규칙을 무시하도록 하려면 해당 glide.security.script.include.name.case.insensitive.list 속성을 사용합니다. 시스템 속성 [sys_properties] 테이블에서 이 속성을 수정하고 인증을 처리하는 데 필요한 스크립트 포함을 추가할 수 있습니다. 기본적으로 이 속성에는 다음 값이 있습니다.
- BasicAuth
- 사용자 지정 인증
Perl 및 SOAP::Lite 라이브러리를 사용할 때 기본 인증을 제공하기 위해 다음 함수를 구현할 수 있습니다.
sub SOAP :: Transport :: HTTP :: Client :: get_basic_credentials { return 'user_name' => 'password' ; }
- C# .NET VS 2005 또는 이전 버전을 사용하는 경우 다음과 같이 Credentials 개체를 활용할 수 있습니다.
System.Net . ICredentials cred = new System.Net . NetworkCredential ( "user_name", "password" ) ; service . ServiceNow proxy = new service . ServiceNow ( ) ; service . get getService = newservice . get ( ) ; service . getResponse getServiceResponse = new service . getResponse ( ) ; try { proxy . Credentials = cred ; getService . sys_id = "bf522c350a0a140701972dbf876f1610" ; getServiceResponse = proxy . get (getService ) ; catch (Exception ex ) { } - C# .NET VS 2008을 사용하는 경우 다음과 같은 ClientCredentials 개체를 활용할 수 있습니다.
Demo_Incident. ServiceNowSoapClient client = new Test08WebService . Demo_Incident . ServiceNowSoapClient ( ) ; client . ClientCredentials . UserName . UserName = "admin" ; client . ClientCredentials . UserName . Password = "admin" ;그런 다음 app.config 파일에서 다음을 찾아 None 을 Basic 으로 변경하십시오.<transport clientCredentialType= "None" proxyCredentialType= "None" realm= "" /> - NET을 사용할 때 Credentials 개체를 활용하는 것은 다음과 같습니다.
Sub Main() Dim cred As New System.Net.NetworkCredential( "user_name", "password") Dim proxy As New VB_Democm.incident.ServiceNow Dim getIncident As New VB_Democm.incident. get Dim getResponse As New VB_Democm.incident.getResponse proxy.Credentials = cred getIncident.sys_id = "[your sysID here]" getResponse = proxy. get(getIncident) End Sub기본 인증이 켜져 있고 자격 증명이 제공되지 않은 경우 결과 응답은 다음과 같습니다.<html> <head > <title >Apache Tomcat/5.0.28 - Error report </ title > <style > <!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} A {color : black;} A.name {color : black;} HR {color : #525D76;}--> </ style > </ head > <body > <h1 >HTTP Status 401 -\ </ h1 > <HR size = "1" noshade = "noshade" > <p >< b >type </ b > Status report </ p > <p >< b >message </ b > <u >< / u >< / p > <p >< b >description </ b > <u >This request requires HTTP authentication (). </ u >< / p > <HR size = "1" noshade = "noshade" > <h3 >Apache Tomcat/5.0.28 </ h3 > </ body > </ html >