All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.security.containers-integration.adoc Maven / Gradle / Ivy

There is a newer version: 4.1.1
Show newest version
///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2018, 2024 Oracle and/or its affiliates.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= WebServer Integration
:description: Helidon Security WebServer integration
:keywords: helidon, security
:rootdir: {docdir}/../..

include::{rootdir}/includes/se.adoc[]

== WebServer

To integrate xref:../webserver.adoc[web server], add the following dependency to your project's pom.xml file:

[source,xml]
.Maven Dependency
----

    io.helidon.webserver
    helidon-webserver-security

----

===  Configure Security with WebServer


There are two steps to configure security with WebServer:

1. Create a security instance and register it with the server.
2. Protect server routes with optional security features.

[source,java]
.Example using builders
----
include::{sourcedir}/se/security/ContainersIntegrationSnippets.java[tag=snippet_1, indent=0]
----
<1> Register the security feature in the web server, enforce authentication by default
<2> Protect this route with authentication (from defaults) and role "user"

[source,java]
.Example using configuration
----
include::{sourcedir}/se/security/ContainersIntegrationSnippets.java[tag=snippet_2, indent=0]
----
<1> Helper method to load both security and web server security from configuration
<2> Security for this route is defined in the configuration

[source,yaml]
.Example using configuration (YAML)
----
security:
  web-server: # <1>
      defaults:
        authenticate: true
      paths:
        - path: "/service1/[/{*}]"
          methods: ["get"]
          roles-allowed: ["user"]
----
<1> Configuration of integration with web server

include::{rootdir}/includes/security/helidon-endpoints.adoc[]

== Reference
* link:{security-integration-webserver-base-url}/module-summary.html[Helidon WebServer Security Integration]




© 2015 - 2024 Weber Informatics LLC | Privacy Policy