I want to use Apache Shiro and MySQL for my Realm. What tables and fields does Shiro need to work?
Apache Shiro's design goals are to simplify application security by being intuitive and easy to use. Shiro's core design models how most people think about application security - in the context of someone (or something) interacting with an application. Software applications are usually designed based on user stories.
The [users] section of the shiro. ini config file defines the user credentials that are recognized by the SecurityManager. The format is: principal (username) = password, role1, role2, …, role. The roles and their associated permissions are declared in the [roles] section.
Although Apache Shiro is designed to be used to secure any JVM-based application, it is most commonly used to secure a web application. It greatly simplifies how you secure web applications base on simple URL pattern matching and filter chain definitions.
A Realm is essentially a security-specific DAO. Because most of these data sources usually store both authentication data (credentials such as passwords) as well as authorization data (such as roles or permissions), every Shiro Realm can perform both authentication and authorization operations.
Shiro doesn't require database tables to function. Shiro users can use whatever datastore they want to model or manage users, groups, permissions etc.
It is a Shiro Realm's responsibility to act as the bridge to your data (however you want to represent it) and return it in a format that Shiro understands.
Because Shiro does not impose a data model upon you, this is what allows it to work with so many backends (LDAP, Active Directory, RDBMS, File System, etc).
If you want to use an RDBMS as your backing data store, check out Shiro's JdbcRealm source code to give you an idea of what your tables might look like. This is just an example though. You could have any table structure you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With