@@ -39,20 +39,27 @@ <h3> Prgramatically Applying Security</h3>
39
39
< div style ="color:#888 "> This section is not a part of RapiDoc generated doc. It is created using HTML and JS to dempostrate how to programatically apply security keys</ div >
40
40
41
41
< div style ="margin-top:16px ">
42
- RapiDoc provides you with helper methods which you may use to set various security keys programatically.
43
- Helpful in the cases where you like to automatically apply security, instead of asking user to key in
44
- < br /> < br />
42
+ RapiDoc provides you with helper methods which you may use to set supply security keys programatically.
43
+ There are two methods which can be used to set the values needed for various security schemes
44
+ < ol >
45
+ < li > < span style ="font-family:'Roboto Mono' "> setHttpUserNameAndPassword()</ span > </ li >
46
+ < li > < span style ="font-family:'Roboto Mono' "> setApiKey()</ span > </ li >
47
+ </ ol >
45
48
</ div >
46
49
< p >
47
- This spec contains the following security schemes
50
+ The table below list all the scurity schemes included in this spec. Check the corrosponding method that can be used to supply a access-token
48
51
< table class ="table " style ="border:1px solid #444; font-family:'Roboto Mono' ">
49
52
< tr > < th > TYPE</ th > < th > SECURITY SCHEME ID</ th > < th > METHOD USED TO UPDATE</ th > </ tr >
50
- < tr > < td > http</ td > < td > http-basic</ td > < td > RapiDocEl.setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</ td > </ tr >
51
- < tr > < td > http</ td > < td > http-bearer</ td > < td > RapiDocEl.setHttpUserNameAndPassword('http-bearer', 'newUserName', 'newPassword')</ td > </ tr >
52
- < tr > < td > apiKey</ td > < td > api_key1</ td > < td > RapiDocEl.setApiKey('api_key1', 'newApiToken')</ td > </ tr >
53
- < tr > < td > apiKey</ td > < td > api_key2</ td > < td > RapiDocEl.setApiKey('api_key2', 'newApiToken')</ td > </ tr >
54
- < tr > < td > apiKey</ td > < td > api_key_cookie</ td > < td > Not Supported</ td > </ tr >
55
- < tr > < td > oauth2</ td > < td > ms-oauth</ td > < td > ---</ td > </ tr >
53
+ < tr > < td > http</ td > < td > http-basic</ td > < td rowspan ="2 "> RapiDocEl.setHttpUserNameAndPassword('http-basic', 'newUserName', 'newPassword')</ td > </ tr >
54
+ < tr > < td > http</ td > < td > http-bearer</ td > </ tr >
55
+ < tr > < td > oauth2</ td > < td > ms-oauth</ td > < td style ="border-bottom: 1px dashed #383838; " rowspan ="3 "> RapiDocEl.setApiKey('api_key1', 'newApiToken')</ td > </ tr >
56
+ < tr > < td > apiKey</ td > < td > api_key1</ td > </ tr >
57
+ < tr > < td > apiKey</ td > < td > api_key2</ td > </ tr >
58
+ < tr > < td > apiKey</ td > < td > api_key_cookie</ td > < td >
59
+ < span style ="font-family:'Open Sans'; color:#666 ">
60
+ If the apiKey needs to send using a cookie, then it wont be set as RapiDoc do not support creation or reading of cookies
61
+ </ span >
62
+ </ td > </ tr >
56
63
</ table >
57
64
</ p >
58
65
< div style ="margin:32px 0 16px 0; color:#777; font-weight:bold ">
@@ -79,12 +86,8 @@ <h3> Prgramatically Applying Security</h3>
79
86
< tr >
80
87
< td > OAuth</ td >
81
88
< td >
82
- < input class ='size txt ' id ='oauth-security-scheme-id ' type ='text ' placeholder ='Security Scheme ID ' spellcheck ='false ' style ="width:120px ">
83
- < input class ='size txt ' id ='oauth-flow ' type ='text ' placeholder ='OAuth Flow ' spellcheck ='false '>
84
- < input class ='size txt ' id ='oauth-client-id ' type ='text ' placeholder ='client-id ' spellcheck ='false ' >
85
- < input class ='size txt ' id ='oauth-client-secret ' type ='text ' placeholder ='client-secret ' spellcheck ='false ' >
86
- < input class ='size txt ' id ='oauth-username ' type ='text ' placeholder ='Username ' spellcheck ='false ' >
87
- < input class ='size txt ' id ='oauth-password ' type ='text ' placeholder ='password ' spellcheck ='false ' >
89
+ < input class ='size txt ' id ='oauth-security-scheme-id ' value ="ms-oauth " type ='text ' placeholder ='Security Scheme ID ' spellcheck ='false ' style ="width:120px ">
90
+ < input class ='size txt ' id ='oauth-key-value ' type ='text ' value ="new-token " placeholder ='Access Token ' spellcheck ='false ' >
88
91
< button class ='size btn ' onclick ='setSecurity(event, "oauth2") '> Apply</ button >
89
92
</ td >
90
93
</ tr >
@@ -116,7 +119,8 @@ <h3> Prgramatically Applying Security</h3>
116
119
result = docEl . setApiKey ( securitySchemeId , newApiToken ) ;
117
120
} else if ( securityType === 'oauth2' ) {
118
121
const securitySchemeId = trEl . querySelector ( '#oauth-security-scheme-id' ) . value ;
119
- result = docEl . setOauthClientIdAndSecret ( securitySchemeId , 'oauthFlow' , 'clientId' , 'clientSecret' , 'username' , 'password' , 'scopes' ) ;
122
+ const newApiToken = trEl . querySelector ( '#oauth-key-value' ) . value ;
123
+ result = docEl . setApiKey ( securitySchemeId , newApiToken ) ;
120
124
}
121
125
ev . target . innerText = result ? 'Applied !' : 'Failed' ;
122
126
ev . target . style . backgroundColor = result ? 'green' : 'orangered' ;
0 commit comments