Skip to content

Commit

Permalink
fix: 修改 policy injector_func 函数入参;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Aug 2, 2021
1 parent a48ff78 commit 4b80766
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions packages/app-server/src/lib/policy-agent/policy-agent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert = require("assert")
import { AccessorInterface, Policy } from "less-api"
import { AccessorInterface, Params, Policy } from "less-api"
import { CloudFunction } from "../../../../cloud-function-engine/dist"
import { getFunctionByName } from "../../api/function"
import { Globals } from "../globals/globals"
Expand Down Expand Up @@ -63,11 +63,12 @@ export class PolicyAgent implements PolicyAgentInterface {

/**
* 默认的 injection getter
* @param uid
* @param auth 为 jwt token 的 payload 对象
* @returns 返回默认的 injections
*/
async function defaultInjectionGetter(uid: string) {
async function defaultInjectionGetter(auth: any, _params: Params) {
auth = auth || {}
return {
$uid: uid
...auth
}
}
2 changes: 1 addition & 1 deletion packages/app-server/src/lib/policy-agent/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Params, Policy } from "less-api"



export type InjectionGetter = (uid: string, params: Params) => Promise<any>
export type InjectionGetter = (payload: string, params: Params) => Promise<any>

/**
* used in policy agent
Expand Down
2 changes: 1 addition & 1 deletion packages/app-server/src/router/entry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ EntryRouter.post('/proxy/:policy', async (req, res) => {
const params = proxy.parseParams({ ...req.body, requestId })

// get injections
const injections = await policyComposition.injector_func(auth.uid, params)
const injections = await policyComposition.injector_func(auth, params)

// validate query
const result = await proxy.validate(params, injections)
Expand Down

0 comments on commit 4b80766

Please sign in to comment.