sap-tutorials / Tutorials

Tutorials on sap.com
https://developers.sap.com/tutorial-navigator.html
Creative Commons Attribution 4.0 International
721 stars 773 forks source link

Add Authentication and Authorization to the Application #23417

Closed DichoMire closed 6 months ago

DichoMire commented 8 months ago

Tutorials: https://developers.sap.com/tutorials/cp-cap-java-security-local.html

At step three you have a section stating that you need to place the following code block in your application.yaml:

---
spring:
  config.activate.on-profile: default
cds:
  datasource:
    auto-config.enabled: false
  security:
    mock:
      users:
        - name: klaus
          password: pass_klaus
          additional:
            firstName: Klaus
            lastName: Sussard
            email: Klaus.Sussard@mail.com
        - name: mia
          password: pass_mia
          additional:
            firstName: Mia
            lastName: Bonnellac
            email: Mia.Bonnellac@mail.com

However, this causes several errors during deployment:

2024-01-29T13:00:36.082Z  INFO 12146 --- [  restartedMain] c.s.c.s.impl.runtime.CdsRuntimeImpl      : Exception marked the ChangeSet 3 as cancelled: Error executing the statement (service 'PersistenceService$Default', event 'CREATE', entity 'sap.capire.products.Products')
2024-01-29T13:00:36.086Z  INFO 12146 --- [  restartedMain] c.s.c.s.impl.runtime.CdsRuntimeImpl      : Exception marked the ChangeSet 4 as cancelled: Error executing the statement (service 'PersistenceService$Default', event 'CREATE', entity 'sap.capire.bookstore.Authors')
2024-01-29T13:00:36.090Z  INFO 12146 --- [  restartedMain] c.s.c.s.impl.runtime.CdsRuntimeImpl      : Exception marked the ChangeSet 5 as cancelled: Error executing the statement (service 'PersistenceService$Default', event 'CREATE', entity 'sap.capire.products.Products.texts')
2024-01-29T13:00:36.093Z  INFO 12146 --- [  restartedMain] c.s.c.s.impl.runtime.CdsRuntimeImpl      : Exception marked the ChangeSet 6 as cancelled: Error executing the statement (service 'PersistenceService$Default', event 'CREATE', entity 'sap.capire.products.Categories')

This is the original application.yaml as it's created by Maven:

---
spring:
  config.activate.on-profile: default
  sql.init.schema-locations: classpath:schema-h2.sql
cds:
  datasource.auto-config.enabled: false

You can fix the error by adding the line: sql.init.schema-locations: classpath:schema-h2.sql

renejeglinsky commented 8 months ago

Thanks @DichoMire, I'll check that and get back to you soon :)

renejeglinsky commented 6 months ago

Hi @DichoMire ,

thanks for your report. I fixed it now with the linked PR.

All the best, René