Skip to content

Commit 3d1984a

Browse files
authored
Merge pull request #437 from scouter-project/develop
Develop
2 parents 74251c9 + 32a8203 commit 3d1984a

File tree

8 files changed

+183
-14
lines changed

8 files changed

+183
-14
lines changed

scouter.document/main/Configuration.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ public int sfa_dump_interval_ms = 10000;
351351
//miscellaneous
352352
@ConfigDesc("User ID based(0 : Remote Address, 1 : JSessionID, 2 : Scouter Cookie)")
353353
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:SetCookie
354+
@ConfigDesc("Setting a cookie path for SCOUTER cookie when trace_user_mode is 2")
355+
public String trace_user_cookie_path = "/";
354356

355357
@ConfigDesc("Path to file creation directory of process ID file")
356358
public String counter_object_registry_path = "/tmp/scouter";

scouter.document/main/Configuration_kr.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ public int sfa_dump_interval_ms = 10000;
351351
//miscellaneous
352352
@ConfigDesc("User ID based(0 : Remote Address, 1 : JSessionID, 2 : Scouter Cookie)")
353353
public int trace_user_mode = 2; // 0:Remote IP, 1:JSessionID, 2:SetCookie
354+
@ConfigDesc("Setting a cookie path for SCOUTER cookie when trace_user_mode is 2")
355+
public String trace_user_cookie_path = "/";
354356

355357
@ConfigDesc("Path to file creation directory of process ID file")
356358
public String counter_object_registry_path = "/tmp/scouter";

scouter.document/tech/Web-API-Guide.md

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ public String net_http_api_auth_ip_header_key;
8484

8585
@ConfigDesc("Enable api access control by JSESSIONID of Cookie")
8686
public boolean net_http_api_auth_session_enabled = true;
87-
@ConfigDesc("api http session timeout")
87+
@ConfigDesc("api http session timeout(sec)")
8888
public int net_http_api_session_timeout = 3600*24;
89+
@ConfigDesc("Enable api access control by Bearer token(of Authorization http header) - get access token from /user/loginGetToken.")
90+
public boolean net_http_api_auth_bearer_token_enabled = false;
8991

9092
@ConfigDesc("api access allow ip addresses")
9193
@ConfigValueType(ValueType.COMMA_SEPARATED_VALUE)
@@ -399,21 +401,77 @@ public int log_keep_days = 30;
399401
- `serverId` : (optional if single server)
400402

401403
#### - `GET /v1/kv/{key}`
402-
- get value of given key from scouter server's key-value store
404+
- get value of given key from the scouter server's key-value store. (in the global key space)
403405
- **Auth** : required
404406
- **Path params**
405407
- `key` : (required)
406408
- **Query params**
407409
- `serverId` : (optional if single server)
408410

409411
#### - `PUT /v1/kv`
410-
- set key and value and store it to scouter server's key-value store
412+
- store it to the scouter server's key-value store. (in the global key space)
411413
- **Auth** : required
412414
- **Request body (type : application/json)**
413415
- `key` : (required)
414416
- `value` : (required)
415417
- `serverId` : (required)
416418

419+
#### - `GET /v1/kv/{keys}/:bulk`
420+
- get values of given keys from the scouter server's key-value store. (in the global key space)
421+
- **Auth** : required
422+
- **Path params**
423+
- `keys` : (required) keys by comma separator. also allowed with bracket. eg) mykey-1,mykey2 or [mykey-1,mykey2]
424+
- **Query params**
425+
- `serverId` : (optional if single server)
426+
427+
#### - `PUT /v1/kv/:bulk`
428+
- store key&values to the scouter server's key-value store. (in the global key space)
429+
- **Auth** : required
430+
- **Request body (type : application/json)**
431+
- `kvList` : (required) array of key & value
432+
- `key` : (required)
433+
- `value` : (required)
434+
- `serverId` : (required)
435+
436+
#### - `GET /v1/kv/space/{keySpace}/{key}`
437+
- get value of given key from the key space of scouter server's key-value store.
438+
- **Auth** : required
439+
- **Path params**
440+
- `keySpace` : (required)
441+
- `key` : (required)
442+
- **Query params**
443+
- `serverId` : (optional if single server)
444+
445+
#### - `PUT /v1/kv/space/{keySpace}`
446+
- store it to the key space of scouter server's key-value store
447+
- **Auth** : required
448+
- **Path params**
449+
- `keySpace` : (required)
450+
- **Request body (type : application/json)**
451+
- `key` : (required)
452+
- `value` : (required)
453+
- `serverId` : (required)
454+
455+
#### - `GET /v1/kv/space/{keySpace}/{keys}/:bulk`
456+
- get values of given keys from the key space of scouter server's key-value store
457+
- **Auth** : required
458+
- **Path params**
459+
- `keySpace` : (required)
460+
- `keys` : (required) keys by comma separator. also allowed with bracket. eg) mykey-1,mykey2 or [mykey-1,mykey2]
461+
- **Query params**
462+
- `serverId` : (optional if single server)
463+
464+
#### - `PUT /v1/kv/space/{keySpace}/:bulk`
465+
- store key&values to the key space of scouter server's key-value store
466+
- **Auth** : required
467+
- **Path params**
468+
- `keySpace` : (required)
469+
- **Request body (type : application/json)**
470+
- `kvList` : (required) array of key & value
471+
- `key` : (required)
472+
- `value` : (required)
473+
- `serverId` : (required)
474+
417475
#### - `GET /v1/object/host/realTime/top/ofObject/{objHash}`
418476
- retrieve all OS processes cpu, memory usage of the given object
419477
- **Auth** : required
@@ -422,6 +480,23 @@ public int log_keep_days = 30;
422480
- **Query params**
423481
- `serverId` : (optional if single server)
424482

483+
#### - `PUT /v1/user/loginGetToken`
484+
- login with id & password, and get bearer token.
485+
- this token required on Authorization header for authorized request.
486+
- auth header example : `Authorization: Bearer V1.B3R4FSGEF3POJ.me`
487+
- **Auth** : none
488+
- **Request body (type : application/json)**
489+
- `user` : (required)
490+
- `id` : (required)
491+
- `password` : (required)
492+
- `serverId` : (required)
425493

426-
427-
494+
#### - `PUT /v1/user/login`
495+
- login with id & password for traditional web application.
496+
- this api is answered including with SET-COOKIE response header.
497+
- **Auth** : none
498+
- **Request body (type : application/json)**
499+
- `user` : (required)
500+
- `id` : (required)
501+
- `password` : (required)
502+
- `serverId` : (required)

scouter.document/tech/Web-API-Guide_kr.md

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ If you include this widget path when setting up a custom alarm, you can use it m
6666

6767
## Configuration
6868
```java
69+
6970
@ConfigDesc("Collector connection infos - eg) host:6100:id:pw,host2:6100:id2:pw2")
7071
@ConfigValueType(ValueType.COMMA_SEPARATED_VALUE)
7172
public String net_collector_ip_port_id_pws = "127.0.0.1:6100:admin:admin";
@@ -82,8 +83,10 @@ public String net_http_api_auth_ip_header_key;
8283

8384
@ConfigDesc("Enable api access control by JSESSIONID of Cookie")
8485
public boolean net_http_api_auth_session_enabled = true;
85-
@ConfigDesc("api http session timeout")
86+
@ConfigDesc("api http session timeout(sec)")
8687
public int net_http_api_session_timeout = 3600*24;
88+
@ConfigDesc("Enable api access control by Bearer token(of Authorization http header) - get access token from /user/loginGetToken.")
89+
public boolean net_http_api_auth_bearer_token_enabled = false;
8790

8891
@ConfigDesc("api access allow ip addresses")
8992
@ConfigValueType(ValueType.COMMA_SEPARATED_VALUE)
@@ -397,21 +400,77 @@ public int log_keep_days = 30;
397400
- `serverId` : (optional if single server)
398401

399402
#### - `GET /v1/kv/{key}`
400-
- get value of given key from scouter server's key-value store
403+
- get value of given key from the scouter server's key-value store. (in the global key space)
401404
- **Auth** : required
402405
- **Path params**
403406
- `key` : (required)
404407
- **Query params**
405408
- `serverId` : (optional if single server)
406409

407410
#### - `PUT /v1/kv`
408-
- set key and value and store it to scouter server's key-value store
411+
- store it to the scouter server's key-value store. (in the global key space)
409412
- **Auth** : required
410413
- **Request body (type : application/json)**
411414
- `key` : (required)
412415
- `value` : (required)
413416
- `serverId` : (required)
414417

418+
#### - `GET /v1/kv/{keys}/:bulk`
419+
- get values of given keys from the scouter server's key-value store. (in the global key space)
420+
- **Auth** : required
421+
- **Path params**
422+
- `keys` : (required) keys by comma separator. also allowed with bracket. eg) mykey-1,mykey2 or [mykey-1,mykey2]
423+
- **Query params**
424+
- `serverId` : (optional if single server)
425+
426+
#### - `PUT /v1/kv/:bulk`
427+
- store key&values to the scouter server's key-value store. (in the global key space)
428+
- **Auth** : required
429+
- **Request body (type : application/json)**
430+
- `kvList` : (required) array of key & value
431+
- `key` : (required)
432+
- `value` : (required)
433+
- `serverId` : (required)
434+
435+
#### - `GET /v1/kv/space/{keySpace}/{key}`
436+
- get value of given key from the key space of scouter server's key-value store.
437+
- **Auth** : required
438+
- **Path params**
439+
- `keySpace` : (required)
440+
- `key` : (required)
441+
- **Query params**
442+
- `serverId` : (optional if single server)
443+
444+
#### - `PUT /v1/kv/space/{keySpace}`
445+
- store it to the key space of scouter server's key-value store
446+
- **Auth** : required
447+
- **Path params**
448+
- `keySpace` : (required)
449+
- **Request body (type : application/json)**
450+
- `key` : (required)
451+
- `value` : (required)
452+
- `serverId` : (required)
453+
454+
#### - `GET /v1/kv/space/{keySpace}/{keys}/:bulk`
455+
- get values of given keys from the key space of scouter server's key-value store
456+
- **Auth** : required
457+
- **Path params**
458+
- `keySpace` : (required)
459+
- `keys` : (required) keys by comma separator. also allowed with bracket. eg) mykey-1,mykey2 or [mykey-1,mykey2]
460+
- **Query params**
461+
- `serverId` : (optional if single server)
462+
463+
#### - `PUT /v1/kv/space/{keySpace}/:bulk`
464+
- store key&values to the key space of scouter server's key-value store
465+
- **Auth** : required
466+
- **Path params**
467+
- `keySpace` : (required)
468+
- **Request body (type : application/json)**
469+
- `kvList` : (required) array of key & value
470+
- `key` : (required)
471+
- `value` : (required)
472+
- `serverId` : (required)
473+
415474
#### - `GET /v1/object/host/realTime/top/ofObject/{objHash}`
416475
- retrieve all OS processes cpu, memory usage of the given object
417476
- **Auth** : required
@@ -420,6 +479,23 @@ public int log_keep_days = 30;
420479
- **Query params**
421480
- `serverId` : (optional if single server)
422481

482+
#### - `PUT /v1/user/loginGetToken`
483+
- login with id & password, and get bearer token.
484+
- this token required on Authorization header for authorized request.
485+
- auth header example : `Authorization: Bearer V1.B3R4FSGEF3POJ.me`
486+
- **Auth** : none
487+
- **Request body (type : application/json)**
488+
- `user` : (required)
489+
- `id` : (required)
490+
- `password` : (required)
491+
- `serverId` : (required)
423492

424-
425-
493+
#### - `PUT /v1/user/login`
494+
- login with id & password for traditional web application.
495+
- this api is answered including with SET-COOKIE response header.
496+
- **Auth** : none
497+
- **Request body (type : application/json)**
498+
- `user` : (required)
499+
- `id` : (required)
500+
- `password` : (required)
501+
- `serverId` : (required)

scouter.webapp/src/main/java/scouterx/webapp/layer/controller/ProfileController.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818

1919
package scouterx.webapp.layer.controller;
2020

21+
import io.swagger.annotations.Api;
2122
import lombok.extern.slf4j.Slf4j;
2223
import scouter.lang.step.Step;
23-
import scouterx.webapp.view.CommonResultView;
24-
import scouterx.webapp.request.ProfileRequest;
2524
import scouterx.webapp.layer.service.ProfileService;
25+
import scouterx.webapp.request.ProfileRequest;
26+
import scouterx.webapp.view.CommonResultView;
2627

2728
import javax.inject.Singleton;
2829
import javax.validation.Valid;
@@ -37,6 +38,7 @@
3738
* @author Gun Lee (gunlee01@gmail.com) on 2017. 9. 3.
3839
*/
3940
@Path("/v1/profile")
41+
@Api("Raw profile")
4042
@Singleton
4143
@Produces(MediaType.APPLICATION_JSON)
4244
@Slf4j

scouter.webapp/src/main/java/scouterx/webapp/layer/controller/UserController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package scouterx.webapp.layer.controller;
2020

21+
import io.swagger.annotations.Api;
2122
import scouterx.webapp.framework.annotation.NoAuth;
2223
import scouterx.webapp.framework.client.server.Server;
2324
import scouterx.webapp.framework.client.server.ServerManager;
@@ -32,7 +33,6 @@
3233
import javax.inject.Singleton;
3334
import javax.servlet.http.HttpServletRequest;
3435
import javax.validation.Valid;
35-
import javax.ws.rs.BeanParam;
3636
import javax.ws.rs.Consumes;
3737
import javax.ws.rs.POST;
3838
import javax.ws.rs.Path;
@@ -47,6 +47,7 @@
4747
* @author Gun Lee (gunlee01@gmail.com) on 2017. 8. 27.
4848
*/
4949
@Path("/v1/user")
50+
@Api("User")
5051
@Singleton
5152
@Produces(MediaType.APPLICATION_JSON)
5253
public class UserController {
@@ -64,7 +65,7 @@ public class UserController {
6465
@NoAuth
6566
@POST @Path("/login")
6667
@Consumes(MediaType.APPLICATION_JSON)
67-
public CommonResultView<Boolean> login(@BeanParam @Valid final LoginRequest loginRequest) {
68+
public CommonResultView<Boolean> login(@Valid final LoginRequest loginRequest) {
6869
userService.login(ServerManager.getInstance().getServer(loginRequest.getServerId()), loginRequest.getUser());
6970
servletRequest.getSession(true).setAttribute("user", new SUser(loginRequest.getUser().getId()));
7071

scouter.webapp/src/main/java/scouterx/webapp/layer/controller/XLogController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package scouterx.webapp.layer.controller;
2020

2121
import com.fasterxml.jackson.core.JsonGenerator;
22+
import io.swagger.annotations.Api;
2223
import lombok.extern.slf4j.Slf4j;
2324
import scouter.lang.constants.ParamConstant;
2425
import scouter.lang.pack.MapPack;
@@ -55,6 +56,7 @@
5556
* @author Gun Lee (gunlee01@gmail.com) on 2017. 8. 29.
5657
*/
5758
@Path("/v1/xlog")
59+
@Api("Raw xlog")
5860
@Singleton
5961
@Produces(MediaType.APPLICATION_JSON)
6062
@Slf4j

scouter.webapp/src/main/java/scouterx/webapp/swagger/Bootstrap.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package scouterx.webapp.swagger;
22

33
import io.swagger.jaxrs.config.BeanConfig;
4+
import io.swagger.jaxrs.config.SwaggerContextService;
5+
import io.swagger.models.Swagger;
6+
import io.swagger.models.auth.ApiKeyAuthDefinition;
7+
import io.swagger.models.auth.In;
48
import lombok.extern.slf4j.Slf4j;
59
import org.apache.commons.lang3.StringUtils;
610
import scouterx.webapp.framework.configure.ConfigureAdaptor;
@@ -43,5 +47,10 @@ public void init(ServletConfig config) throws ServletException {
4347
beanConfig.setResourcePackage("scouterx.webapp");
4448
beanConfig.setFilterClass(this.filterClass);
4549
beanConfig.setScan(true);
50+
51+
Swagger swagger = new Swagger();
52+
swagger.securityDefinition("Scouter auth token", new ApiKeyAuthDefinition("Authorization", In.HEADER));
53+
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
54+
4655
}
4756
}

0 commit comments

Comments
 (0)