Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
2de823d2
Commit
2de823d2
authored
Jan 12, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
f7a496f9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
12 deletions
+47
-12
center-channel/app/base/api/impl/auth/accessAuth.js
+15
-1
center-channel/app/base/db/cache/appTokenByHostsCache.js
+2
-5
center-channel/app/base/service/impl/utilsSve/utilsAuthSve.js
+18
-4
center-channel/app/config/routes/api.js
+2
-2
center-channel/app/front/entry/public/apidoc/appDesc/newDemoDesc.md
+10
-0
No files found.
center-channel/app/base/api/impl/auth/accessAuth.js
View file @
2de823d2
...
@@ -81,7 +81,21 @@ class AccessAuthAPI extends APIBase {
...
@@ -81,7 +81,21 @@ class AccessAuthAPI extends APIBase {
*/
*/
async
getAppTokenByHosts
(
pobj
,
qobj
,
req
)
{
async
getAppTokenByHosts
(
pobj
,
qobj
,
req
)
{
var
token
=
this
.
getUUID
();
var
token
=
this
.
getUUID
();
var
opResult
=
await
this
.
utilsAuthSve
.
getReqTokenByHosts
(
pobj
.
actionBody
.
app_hosts
,
token
);
pobj
.
actionBody
.
reqType
=
"hosts"
;
var
opResult
=
await
this
.
utilsAuthSve
.
getReqTokenByHosts
(
pobj
.
actionBody
,
token
);
if
(
opResult
.
status
!=
0
)
{
return
opResult
;
}
return
system
.
getResultSuccess
({
token
:
token
})
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async
getAppTokenByAppKey
(
pobj
,
qobj
,
req
)
{
var
token
=
this
.
getUUID
();
pobj
.
actionBody
.
reqType
=
"appkey"
;
var
opResult
=
await
this
.
utilsAuthSve
.
getReqTokenByHosts
(
pobj
.
actionBody
,
token
);
if
(
opResult
.
status
!=
0
)
{
if
(
opResult
.
status
!=
0
)
{
return
opResult
;
return
opResult
;
}
}
...
...
center-channel/app/base/db/cache/appTokenByHostsCache.js
View file @
2de823d2
...
@@ -13,11 +13,8 @@ class AppTokenByHostsCache extends CacheBase {
...
@@ -13,11 +13,8 @@ class AppTokenByHostsCache extends CacheBase {
return
settings
.
cacheprefix
+
"_accesskey:"
;
return
settings
.
cacheprefix
+
"_accesskey:"
;
}
}
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
async
buildCacheVal
(
cachekey
,
inputkey
,
val
,
ex
,
...
items
)
{
var
app_hosts
=
val
;
var
actionBody
=
val
;
if
(
!
app_hosts
)
{
var
acckapp
=
await
this
.
restClient
.
execPost
(
actionBody
,
settings
.
centerAppUrl
()
+
"auth/accessAuth/getTokenByHosts"
);
return
system
.
getResult
(
null
,
"app_hosts can not be empty"
);
}
var
acckapp
=
await
this
.
restClient
.
execPost
({
app_hosts
:
app_hosts
},
settings
.
centerAppUrl
()
+
"auth/accessAuth/getTokenByHosts"
);
var
result
=
acckapp
.
stdout
;
var
result
=
acckapp
.
stdout
;
console
.
log
(
acckapp
.
stdout
,
"AppTokenByHostsCache............. acckapp.stdout.........."
)
console
.
log
(
acckapp
.
stdout
,
"AppTokenByHostsCache............. acckapp.stdout.........."
)
if
(
result
)
{
if
(
result
)
{
...
...
center-channel/app/base/service/impl/utilsSve/utilsAuthSve.js
View file @
2de823d2
...
@@ -29,13 +29,27 @@ class UtilsAuthSve extends AppServiceBase {
...
@@ -29,13 +29,27 @@ class UtilsAuthSve extends AppServiceBase {
//---------------登录-----------------------------------------------------
//---------------登录-----------------------------------------------------
async
getReqTokenByHosts
(
a
ppHosts
,
tokenValue
)
{
//获取token
async
getReqTokenByHosts
(
a
ctionBody
,
tokenValue
)
{
//获取token
if
(
!
appHosts
)
{
if
(
[
"hosts"
,
"appkey"
].
indexOf
(
actionBody
.
reqType
)
<
0
)
{
return
system
.
getResult
(
null
,
"a
ppHosts can not be empty
"
);
return
system
.
getResult
(
null
,
"a
ctionBody.reqType is error
"
);
}
}
var
result
=
await
this
.
cacheManager
[
"AppTokenByHostsCache"
].
cache
(
tokenValue
,
appHosts
,
system
.
exTime
);
if
(
actionBody
.
reqType
==
"hosts"
)
{
if
(
!
actionBody
.
appHosts
)
{
return
system
.
getResult
(
null
,
"actionBody.appHosts can not be empty"
);
}
}
if
(
actionBody
.
reqType
==
"appkey"
)
{
if
(
!
actionBody
.
appkey
)
{
return
system
.
getResult
(
null
,
"actionBody.appkey can not be empty"
);
}
if
(
!
actionBody
.
secret
)
{
return
system
.
getResult
(
null
,
"actionBody.secret can not be empty"
);
}
}
var
result
=
await
this
.
cacheManager
[
"AppTokenByHostsCache"
].
cache
(
tokenValue
,
actionBody
,
system
.
exTime
);
return
result
;
return
result
;
}
}
async
getReqUserPinByLgoin
(
pobj
,
actionBody
)
{
async
getReqUserPinByLgoin
(
pobj
,
actionBody
)
{
if
(
!
actionBody
.
userName
)
{
if
(
!
actionBody
.
userName
)
{
return
system
.
getResult
(
null
,
"actionBody.userName can not be empty"
);
return
system
.
getResult
(
null
,
"actionBody.userName can not be empty"
);
...
...
center-channel/app/config/routes/api.js
View file @
2de823d2
...
@@ -14,8 +14,8 @@ module.exports = function (app) {
...
@@ -14,8 +14,8 @@ module.exports = function (app) {
res
.
end
(
JSON
.
stringify
(
result
));
res
.
end
(
JSON
.
stringify
(
result
));
return
;
return
;
}
}
if
(
req
.
body
.
actionType
==
"getAppTokenByHosts"
)
{
if
(
[
"getAppTokenByHosts"
,
"getAppTokenByAppKey"
].
indexOf
(
req
.
body
.
actionType
)
>=
0
)
{
req
.
body
.
actionBody
.
app
_h
osts
=
req
.
host
;
req
.
body
.
actionBody
.
app
H
osts
=
req
.
host
;
next
();
next
();
return
;
return
;
}
}
...
...
center-channel/app/front/entry/public/apidoc/appDesc/newDemoDesc.md
View file @
2de823d2
...
@@ -15,6 +15,16 @@
...
@@ -15,6 +15,16 @@
"actionBody"
:{}
"actionBody"
:{}
}
}
```
```
##### 或
```
javascript
{
"actionType"
:
"getAppTokenByHosts"
,
//固定写法就行
"actionBody"
:{
"appkey"
:
"2019090811"
,
//Y string appkey
"secret"
:
"f99d413b767f09b5dff0b3610366cc46"
//Y string 密钥
}
}
```
#### 返回结果
#### 返回结果
```
javascript
```
javascript
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment