default-datasource.md 2.7 KB
Newer Older
sinat_25235033's avatar
sinat_25235033 已提交
1
## Default Document Config DataSource     
2

3 4 5 6 7
Sureness need dataSource to authenticate and authorize, eg: role data, user data etc.  
The dataSource can load from txt, dataBase or no dataBase etc.
We provide interfaces `SurenessAccountProvider`, `PathTreeProvider` for user implement to load data from the dataSource where they want.
Also, we provide default dataSource implement which load dataSource from txt(sureness.yml), user can defined their data in sureness.yml. 
eg:  
8
```
sinat_25235033's avatar
sinat_25235033 已提交
9
## -- sureness.yml document dataSource-- ##
10

11 12
# load api resource which need be protected, config role who can access these resource.
# resources that are not configured are also authenticated and protected by default, but not authorized
13 14
# eg: /api/v2/host===post===[role2,role3,role4] means /api/v2/host===post can be access by role2,role3,role4
# eg: /api/v1/getSource3===get===[] means /api/v1/getSource3===get can not be access by any role
15 16 17 18 19 20 21 22 23 24 25 26 27
resourceRole:
  - /api/v2/host===post===[role2,role3,role4]
  - /api/v2/host===get===[role2,role3,role4]
  - /api/v2/host===delete===[role2,role3,role4]
  - /api/v2/host===put===[role2,role3,role4]
  - /api/mi/**===put===[role2,role3,role4]
  - /api/v1/getSource1===get===[role1,role2]
  - /api/v2/getSource2/*/*===get===[role2]
  - /api/v1/source1===get===[role2]
  - /api/v1/source1===post===[role1]
  - /api/v1/source1===delete===[role3]
  - /api/v1/source1===put===[role1,role2]
  - /api/v1/source2===get===[]
28
  - /api/v3/source===*===[role2]
29

30
# load api resource which do not need be protected, means them need be excluded.
31
# these api resource can be access by everyone
32 33 34 35
excludedResource:
  - /api/v3/host===get
  - /api/v3/book===get
  - /api/v1/account/auth===post
sinat_25235033's avatar
sinat_25235033 已提交
36 37 38 39
  - /**/*.html===get
  - /**/*.js===get
  - /**/*.css===get
  - /**/*.ico===get
40
  - /**/*.png===*
41

42
# account info
43 44
# there are three account: admin, root, tom
# eg: admin has [role1,role2] ROLE, unencrypted password is admin, encrypted password is 0192023A7BBD73250516F069DF18B500
sinat_25235033's avatar
sinat_25235033 已提交
45 46
# eg: root has role1, unencrypted password is 23456
# eg: tom has role3, unencrypted password is 32113
47 48
account:
  - appId: admin
49
    # if add salt, the password is encrypted password - the result: MD5(password+salt)
sinat_25235033's avatar
sinat_25235033 已提交
50
    # digest auth not support encrypted password
51
    # if no salt, the password is unencrypted password
52 53 54 55 56 57 58 59
    credential: 0192023A7BBD73250516F069DF18B500
    salt: 123
    role: [role1,role2]
  - appId: root
    credential: 23456
    role: [role1]
  - appId: tom
    credential: 32113
sinat_25235033's avatar
sinat_25235033 已提交
60
    role: [role3]
61 62 63

```

64 65
If the configuration resource data comes from text, please refer to  [10 Minute Tutorial's Program--sample-bootstrap](sample-bootstrap.md)     
If the configuration resource data comes from dataBase, please refer to  [30 Minute Tutorial's Program--sample-tom](sample-tom.md)