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

Setup starter with optional keys in application.yaml #106

Closed
clun opened this issue May 9, 2020 · 7 comments · Fixed by #254 or #260
Closed

Setup starter with optional keys in application.yaml #106

clun opened this issue May 9, 2020 · 7 comments · Fixed by #254 or #260
Assignees
Labels
🚀 ready for release The issue/feature has been solved and ready for release ✨ enhancement New feature request

Comments

@clun
Copy link
Contributor

clun commented May 9, 2020

Is your feature request related to a problem? Please describe.
When you importing the spring-boot-starter in your application you may asking yourself what are the beans you should create and which ones are already available. As far as I understand:

  • you need to define ff4j
  • you need to define and expose the web console if you want it (FF4jDispatcherServlet)
  • The rest Api is always there but you can enable the swagger doc with a an annotation.

Describe the solution you'd like
What about creating dedicated keys in the application.yaml for ff4j enabling or disabling some beans. Also we can secure the web-console with login/password out of the box with spring security. This is what it look like :

ff4j:
  webconsole:
    enable: true
    url: /ff4j-web-console
    secure: true
    username: admin
    password: ff4j
  rest-api:
    enable: true 
    url: /api/ff4j
    secure: true
    username: admin
    password: ff4j

I have created a working sample for the web-console part here

I also IMO module ff4j-web should be a dependency of the starter. You can still exclude if you don't want it but must of people using the starter what the we console.

With that perspective, only the ff4j bean is required in your app everything else is configuration. FF4j is such a complex object with different stores and properties that for now i don't see it yaml but later what about a constructor with a yaml in the ff4j object.

@clun clun changed the title Setup ff4j with through dedicated keys in application.yaml Setup ff4j by setting keys in application.yaml (but default values) May 9, 2020
@clun clun changed the title Setup ff4j by setting keys in application.yaml (but default values) Setup ff4j by setting keys in application.yaml May 9, 2020
@clun clun changed the title Setup ff4j by setting keys in application.yaml Setup ff4j by setting optional keys in application.yaml May 9, 2020
@clun clun changed the title Setup ff4j by setting optional keys in application.yaml Setup starter with optional keys in application.yaml May 9, 2020
@paul58914080 paul58914080 self-assigned this May 17, 2020
@paul58914080 paul58914080 added the ✨ enhancement New feature request label May 17, 2020
@paul58914080
Copy link
Member

paul58914080 commented Nov 20, 2021

Hello @clun ,

I would have something like this for the configuration

ff4j:
  audit: true # default is 'false'
  security:
    username: admin
    password: ff4j   
  web-console:
   context-path: /ff4j-web-console # default is '/ff4j-web-console'
  rest-api:
    enable-swagger: true # default is 'true'
  • just having rest-api.enable kind of misleads whether or not Restful web api is enabled or not. Whereas we want to have swagger to be enabled or not
  • Not sure the reason of having rest-api.url, so I have removed it.
  • secure seemed redundant between web-console and rest-api hence made it common and removed enable property as I would be conditionally evaluating it based on username and password

Let me know what you think.

@clun
Copy link
Contributor Author

clun commented Nov 28, 2021

I think if it very good.

  • You want the rest API to be always UP and that make sense in a spring boot starter.
  • The settings you put are only for the Spring boot starter itself.. all good.

I got additional idea here (Optional).

  • Should we also consider other properties in the YAML ? like
    config. I said it because most of the work is already done in ff4j-config-yaml

https://github.com/ff4j/ff4j/blob/master/ff4j-config-yaml/src/test/java/org/ff4j/parser/yaml/YamlParserTest.java

InputStream ymlFile = getClass().getClassLoader().getResourceAsStream("application.yml");
FF4jConfiguration ymlConfig = new YamlParser().parseConfigurationFile(ymlFile);

Thanks

@paul58914080
Copy link
Member

paul58914080 commented Nov 29, 2021

I think is it a very good idea to consider ff4j-yaml-config. I need to further deep dive into it. However in this issue I will first try to target only the following configurations

  • Configuring spring security username and password
  • Configuring web console with context path
  • Configuring enable or disable swagger

For ff4j-yaml-config I have raised a new issue #236 which we will track and implement

@paul58914080
Copy link
Member

paul58914080 commented Mar 26, 2022

Implemented enabling and disabling of springdoc with #245

ff4j:
  springdoc:
    enabled: true # default is 'false'

@paul58914080
Copy link
Member

paul58914080 commented Mar 28, 2022

Implemented enabling and disabling of audit with #254

ff4j:
  audit:
    enabled: true # default is 'false'

@paul58914080
Copy link
Member

Implemented enabling and disabling of web-console with context-path with #255

ff4j:
  web-console:
    enabled: true # default is 'false'
    context-path: /ff4j-web # default is '/ff4j-web-console'

@paul58914080
Copy link
Member

Final configuration looks like this with #260

ff4j:
  api:
    context-path: /api/v1/ff4j     # default '/api/ff4j'
    spring-doc:
      enabled: true                # default 'false'
  audit:
    enabled: true                  # default 'false'
  security:
    enabled: true                  # default 'false'
  web-console:
    context-path: /ff4j-web        # default '/ff4j-web-console'
    enabled: true                  # default 'false'
    security:
      enabled: true                # default 'false'
      username: admin              # default 'admin'
      password: admin              # default 'admin'

@paul58914080 paul58914080 added the 🚀 ready for release The issue/feature has been solved and ready for release label Apr 8, 2022
This was linked to pull requests Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 ready for release The issue/feature has been solved and ready for release ✨ enhancement New feature request
Projects
None yet
2 participants