Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <dependency>
- <groupId>org.keycloak</groupId>
- <artifactId>keycloak-spring-boot-starter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.keycloak</groupId>
- <artifactId>keycloak-spring-security-adapter</artifactId>
- </dependency>
- <dependency>
- <groupId>org.keycloak</groupId>
- <artifactId>keycloak-tomcat8-adapter</artifactId>
- </dependency>
- keycloak.enabled=true
- keycloak.realm=test
- keycloak.auth-server-url=http://localhost:8080/auth
- keycloak.ssl-required=external
- keycloak.resource=rest
- keycloak.bearer-only=true
- keycloak.credentials.secret=<secret>
- keycloak.principal-attribute=preferred_username
- keycloak.security-constraints[0].authRoles[0]=application
- keycloak.security-constraints[0].securityCollections[0].name=spring secured api
- keycloak.security-constraints[0].securityCollections[0].patterns[0]=/api/**
- management.security.enabled=false
- POST /auth/realms/test/protocol/openid-connect/token HTTP/1.1
- Host: localhost:8080
- Cache-Control: no-cache
- Postman-Token: <postman token>
- Content-Type: application/x-www-form-urlencoded
- grant_type=password&client_id=postman&username=root&password=12345678
- GET /api/product HTTP/1.1
- Host: localhost:18888
- Authorization: Bearer <keycloak token from the request above>
- Cache-Control: no-cache
- Postman-Token: <postman token>
- {
- "timestamp": <timestamp>,
- "status": 401,
- "error": "Unauthorized",
- "message": "Full authentication is required to access this resource",
- "path": "/api/product"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement