Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fpapon/shiro-labs
https://github.com/fpapon/shiro-labs
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fpapon/shiro-labs
- Owner: fpapon
- License: apache-2.0
- Created: 2019-02-04T11:31:46.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-20T10:10:32.000Z (over 4 years ago)
- Last Synced: 2024-11-07T20:54:41.176Z (about 2 months ago)
- Language: Java
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Apache Shiro labs
This project is an example to show how to use Apache Shiro for a set of common use cases.
## Test Instructions
This instructions show you how to try on the resources from karaf-security project.
### Building
```
git clone https://github.com/fpapon/shiro-labs.git
cd shiro-labs
mvn -Drat.skip=true -DskipTests install
```### Install Features
*Access Karaf console, add repo and install feature*
```
feature:repo-add mvn:fr.openobject.shiro.labs/karaf-features/1.0.0-SNAPSHOT/xml/features
feature:install shiro-labs-security
```### Config Keys and Account
*Generate private and public keys, and set properties*
Where '$KARAF_HOME' is the Karaf Framework path.
```
shiro-labs:generate-keys
```Copy private and public key, then set security.privateKey and security.publicKey properties on $KARAF_HOME/etc/fr.openobject.labs.shiro.karaf.security.cfg
*Create an user account*
```
jdbc:execute jdbc/shiro "insert into SHIRO.USER_ACCOUNT(password, username, id, salt)values('karaf', 'karaf', '1', '1234')"
```### Generate token
*Generate token for user 'karaf' created*
```
shiro-labs:token-create karaf karaf
```
### Validate token*Try token*
Where '$TOKEN' is the string generated from previous step, replace it.```
shiro-labs:token-validate $TOKEN
```### Generate and Validate a token via REST service
*Generate a token*
```
curl -v -X POST -F 'username=karaf' -F 'password=karaf' http://localhost:8181/cxf/shiro-authenticate/token
```*Validate a token*
Where '$TOKEN' is a string generate previous.```
curl -v -H 'Authorization: Bearer $TOKEN' http://localhost:8181/cxf/shiro-authenticate/validate
```