Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.theborakompanioni:thymeleaf-extras-shiro:2.1.0'
}
dependencies {
implementation("com.github.theborakompanioni:thymeleaf-extras-shiro:2.1.0")
}
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>2.1.0</version>
</dependency>
libraryDependencies += "com.github.theborakompanioni" % "thymeleaf-extras-shiro" % "2.1.0"
:dependencies [[com.github.theborakompanioni/thymeleaf-extras-shiro "2.1.0"]]
A Thymeleaf dialect for Apache Shiro tags.
implementation "com.github.theborakompanioni:thymeleaf-extras-shiro:${thymeleaf-shiro.version}"
<dependency>
<groupId>com.github.theborakompanioni</groupId>
<artifactId>thymeleaf-extras-shiro</artifactId>
<version>${thymeleaf-shiro.version}</version>
</dependency>
Download from Maven Central.
git clone https://github.com/theborakompanioni/thymeleaf-extras-shiro.git
<!DOCTYPE html>
<html xmlns:shiro="https://www.github.com/theborakompanioni/thymeleaf-extras-shiro">
<head>
<title>thymeleaf-extras-shiro</title>
</head>
<body>
<p shiro:guest="">Please <a href="login.html">login</a></p>
<p shiro:authenticated="">
Hello, <span shiro:principal=""></span>, how are you today?
</p>
</body>
</html>
The following examples show how to integrate the tags in your Thymeleaf templates. These are all implementations of the examples given in the JSP / GSP Tag Library Section of the Apache Shiro documentation.
Tags can be written in attribute or element notation:
<p shiro:anyTag>
Goodbye cruel World!
</p>
<shiro:anyTag>
<p>Hello World!</p>
</shiro:anyTag>
guest
tag<p shiro:guest="">
Please <a href="login.html">Login</a>
</p>
user
tag<p shiro:user="">
Welcome back John! Not John? Click <a href="login.html">here<a> to login.
</p>
authenticated
tag<a shiro:authenticated="" href="updateAccount.html">Update your contact information</a>
notAuthenticated
tag<p shiro:notAuthenticated="">
Please <a href="login.html">login</a> in order to update your credit card information.
</p>
principal
tag<p>Hello, <span shiro:principal=""></span>, how are you today?</p>
or
<p>Hello, <shiro:principal/>, how are you today?</p>
Typed principal and principal property are also supported.
hasRole
tag<a shiro:hasRole="administrator" href="admin.html">Administer the system</a>
lacksRole
tag<p shiro:lacksRole="administrator">
Sorry, you are not allowed to administer the system.
</p>
hasAllRoles
tag<p shiro:hasAllRoles="developer, project manager">
You are a developer and a project manager.
</p>
hasAnyRoles
tag<p shiro:hasAnyRoles="developer, project manager, administrator">
You are a developer, project manager, or administrator.
</p>
hasPermission
tag<a shiro:hasPermission="user:create" href="createUser.html">Create a new User</a>
lacksPermission
tag<p shiro:lacksPermission="user:delete">
Sorry, you are not allowed to delete user accounts.
</p>
hasAllPermissions
tag<p shiro:hasAllPermissions="user:create, user:delete">
You can create and delete users.
</p>
hasAnyPermissions
tag<p shiro:hasAnyPermissions="user:create, user:delete">
You can create or delete users.
</p>
The project is licensed under the Apache License. See LICENSE for details.