Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User defined policies #79

Open
ahwing210 opened this issue Jul 2, 2017 · 3 comments
Open

User defined policies #79

ahwing210 opened this issue Jul 2, 2017 · 3 comments

Comments

@ahwing210
Copy link

Hi Strongloop Team,

I really like how API Connect's API Designer play well with microgateway.
I have followed this tutorial and the readme.
The tutorial suggested to put the user defined policies inside a "policies" folder and configure the ".apiconnect > config" to refer to this folder.

My question is...
Is there a way I can config where the microgateway (not API Connect/API Designer) to grab the user defined policies?

The reason I am asking is.. I try to something as below:
(1) Follow the "readme" tutorial, in which those built-in policies are clone to my local environment
(2) Go to the project's root and "apic edit"
(3) Configure the ".apiconnect > config" to let API Connect know where my custom policies are stored
(3) Use the API Designer's "Assemble" and pull the "JavaScript" to the panel
(4) [Problem arises here!] API Designer said "This policy is not available on the selected gateway"

I try to put my custom policies in another folder "self-defined-policies" and configure the ".apiconnect > config" to read "self-defined-policies".
After that, API Connect can read the policies properly (without saying "This policy is not available on the selected gateway")
However when I run "sample.js" in the "readme" tutorial, it fails to reference my custom policies..

Thanks for your help

@ozairs
Copy link
Collaborator

ozairs commented Jul 10, 2017

In step 3), the ./apiconfig/connect directory is a directory reference to a policies directory. In the tutorial, the path was relative to the policies directory.

You only need the API Connect designer to view them in the Assembly, so I assume your question is about packaging them for deployment?

@ahwing210
Copy link
Author

Yes.. especially about packaging and deploying the "userPolicies".

I have some new findings. Just want to confirm am I correct.
Finding: microgateway will actually reference the .apiconnect/config to find the "userPolicies" (just like API Connect designer).

Trial 1:

  1. Inside .apiconnect/config, I type { userPolicies: ["self-defined-policies"] }
  2. I copy rate-limiting from policies to self-defined-policies
  3. I type node sample.js in the command prompt

Result: It warns me that Duplicate policy version (rate-limiting:1.0.0) found at: C:/Users/ahwing210/Desktop/testing/api-gateway/self-defined-policies/rate-limiting - skipping

Trial 2:

  1. I remove { userPolicies: ["self-defined-policies"] } from .apiconnect/config.
  2. I copy rate-limiting from policies to self-defined-policies
  3. I type node sample.js in the command prompt

Result: It doesn't warn me anything

@ozairs
Copy link
Collaborator

ozairs commented Jul 16, 2017

Do you also have policies defined at some other location? perhaps in your home directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants