同时提供 XML 文件与数据库两种内容授权实现,便于对照
SknServices — Rails 启动器模板
作者 skoona
基于 Rails 的认证与授权示例应用,用 XML 与数据库两种方式实现内容级权限模型。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
以 ContentProfileEntry 组合 TOPIC 与 CONTENT 结构,描述到具体文档的权限
演示页 ContentProfile Demo 可并列展示同一用户的 XML AccessProfile 与数据库 ContentProfile
包含 Corporate 与 Branch Office 领域模型,围绕佣金对账单等文档的保护场景
使用 PostgreSQL,README 说明可在 JRuby 上运行
模板详细介绍
SknServices 是一个 Rails 应用,用于演示认证(Authentication)、访问授权(Access Authorization)与内容授权(Content Authorization)的实现方式,README 将其分别称为 UserProfiles、AccessProfiles 和 ContentProfiles。项目采用 PostgreSQL,README 说明其可在 JRuby 上运行,并提供了 GitHub Pages 上的演示页面。
内容授权是项目的重点。它把受保护资源抽象为存储容器系统(SCS),示例中选用文件系统:文件路径对应 TOPIC 结构(topic_type、topic_value、description),文件名对应 CONTENT 结构(content_type、content_value、description),两者组合成一条 ContentProfileEntry(CPE),即一条内容授权记录;多条 CPE 组成某个用户的 ContentProfile,并通过 person_authentication_key(PAK/UUID)关联到 UserProfile。
同一套思路有两种实现:ContentProfile 系列类是基于数据库的实现,AccessProfile 系列类是基于 XML 文件的实现,后者源自 Java Access Controller 的权限模型,用于页面、可点击项和流程的访问控制。演示页面 ContentProfile Demo 会列出系统用户,选中后同时展示该用户的 XML AccessProfile 与匹配的数据库 ContentProfile,用于对比两种实现的结果。
项目还包含 Corporate 与 Branch Office 的领域模型,业务背景是保护佣金对账单等文档,并记录分支机构获准承保新业务的州等运营属性。README 称数据库模型是作者更偏好的方案,因为更容易为其构建界面并在新增权限时维护。
适合你的项目吗?
适用场景
- 需要理解或对比 XML 与数据库两种权限建模方式时
- 为文档、对账单等受保护内容设计细粒度授权记录时
- 在 Rails 项目中搭建带认证与授权骨架的起步应用时
- 研究 Java Access Controller 权限模型如何移植到 Ruby 时
适合人群
- 正在评估内容级授权方案的 Rails 开发者
- 需要可运行的认证授权示例作为参考的后端工程师
- 关注 XML 与数据库两种权限存储取舍的技术团队
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需先安装 PostgreSQL,并在 config/settings.yml、config/settings/development.yml(或 development.local.yml)、config/settings/test.yml(或 test.local.yml)中配置数据库凭据
- 2
可设置环境变量 COVERAGE=true 与 BUNDLE_PATH='vendor/bundle';README 提示使用 rvm 会清除这些值,可能需要重新设置
- 3
依次执行 mkdir tmp、bin/setup、rspec,再用 bundle exec rails server Puma -b 0.0.0.0 启动
- 4
应用用户 ID 位于 db/seeds.rb,README 给出的开发者凭据为 developer / developer99
- 5
lib/tasks/profile_tools_task.rake 会在 bin/setup 期间生成内容授权数据库的初始版本
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用前必须自行安装并运行 PostgreSQL 数据库,并在 config/settings.yml 等配置文件中填写数据库凭据,否则应用无法启动。
- 若使用 rvm 管理 Ruby 环境,会清除 COVERAGE、BUNDLE_PATH 等环境变量,需要重新设置后才能正常安装依赖。
- 演示账号与密码来自 db/seeds.rb 种子数据,仅用于本地演示,正式使用需自行替换为真实用户体系。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
You will need to install PostGreSQL, and add/edit PostgreSQL credentials an the Application-Context Configuration YAML files
README 原文
export BUNDLE_PATH='vendor/bundle' Note: use of rvm wipes out all these values, you may need to reset them
README 原文
https://github.com/skoona/SknServices/blob/master/LICENSEhttps://github.com/skoona/SknServices/blob/master/README.mdApplication UserIDs are in the db/seed.rb file. Developer credentials are: username: developer, passwd: developer99
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料一般 · 68 / 100
- 技术栈
- Rails
- 网站类型
- 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2022-07-21
- 截图检查日期
- 2026-10-02
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Rails。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: c5a0e7543aba61415e28509000824ed7a4ad4e9d0dc467167d6df348830da4f7
2026-10-02T19:04:59.932Z
来源文件 / 仓库# SknService
Rails Authorization and Authentication implementation using an alternate MVC strategy.
# Introduction
This is a Rails 5, Ruby 2.3 (JRuby capable), PostgreSQL Application which demonstrates Authentication and Authorization strategies.
My original need was to demonstrate a content authorization methodology, rather than to continue open-ended theoretical discussions. Two
implementaitons would be needed, one based on an existing XML file; modeled after Java's Security Manager and permission. The other implementation would
be a Database driven model that represented the same goal. It is my observation that they both meet my objective, and could both
be used successfully in any application base.
Of the two implementation strategies the database model is my preference, as it would be easier to create a UI to support it and to maintain as new permissions are added. The demonstration
of the final algorithmic result, is the 'ContentProfile Demo' page. It lists all the systems users, and when one is selected it displays
both the XML AccessProfile, and the matching DB ContentProfile.
The algorithm and point being made was: Create a multi-factor authorization/permission record that precisely identifies the business entities a user is assigned to, then precisely identify the
types of content that user is authorized to interact with on behalf of an assigned business entity. I.e For Account number 1104, user UUID can view Commission Document types:96033
After having proven my point, I've decided to share the body of this work and complete it by implementing a Corporate and Branch Office domain model. The initial context of the application
was to provide protection of important business documents like commission statements, and capturing operational attributes like, which states a branch is licensed to quote new business.
Advanced security and authorization features are fully implemented and I think quite usable as a secure starter application.
James,
[more details](https://skoona.blogspot.com/2016/08/sknservices-alternate-development_11.html)

## Description
This application demonstrates and explores methods for Authentication, Access Authorizations,
and Content Authorizations. Referred to as UserProfiles, AccessProfiles, and ContentProfiles in
this application.
* UserProfiles deal with userid, password, password resets, and some preferences management.
* AccessProfiles deal with what each user is allowed to access, click, or view.
* ContentProfiles deal with specific content access privileges; which document, etc. can be retrieved.
UserProfiles and AccessProfiles have many different implementations available, and are well handled processes. The [Java Access Controller](http://www.cs.ait.ac.th/~on/O/oreilly/java-ent/security/ch05_01.htm "Java Access Controller"), and related classes,
were the original template for the AccessRegistry or AccessProfile capability; This now is an enhanced Ruby port of those permission capabilities. However,
ContentProfiles are the main focus of exploration in this app, which has proven to be a significant
engineering challenge when it comes to handling the dynamics of Electronic Delivery.
### Core Idea
#### ContentProfile and AccessProfile are implementations of the same core idea, with side benefits. For lack of a better term: ContentProfile is the label adopted to represent that core idea.
For content authorization there is an assumption that protected resources are classified and stored in some type of storage container system(SCS). An SCS might actually be a simple FileSystem or
a enterprise class document management systems. In any event, retrieving items would require we specify some meta-data to retrieve a single document/item and different meta-data to retrieve a collection of typed documents.
I chose a FileSystem as the SCS for this demo application, so filename implies a specific instance of a thing, and filename with wildcards implies a collection of things, and the file path is identity meta-data.
Filepaths become part of the TOPIC structure, while filenames become part of the CONTENT structure. A ContentProfile entry will have both structures present.
The TOPIC structure is composed of three elements,
- topic_type: :string some type of business entity like a branch, agency, store, etc.
- topic_value: :array-of-strings the identifier for this entity; branch number, agency number, store number, any hard and unique reference.
- description: :string label for this component
The CONTENT structure is composed of three elements,
- content_type: :string textual type of item or document; commission statement, 1099 document, budget spreadsheet, etc.
- content_value: :array-of-strings either the collection name for this type of content, or it's specific ID
- description: :string label for this component
The container for these two structures is defined as a ContentProfileEntry(CPE), which would be composed of these two structures and a descriptive label. CPEs are the final content authorization permission record.
A user is considered to have permission to specific content only if a related CPE exists in their ContentProfile.
One ContentProfileEntry describes one permission, through the combination of a fully qualified content type identifiers and topic type identifiers. It is expected that a
user's collection would have many of these specialized entries, and that some entries may be shareable (reducing redundancy) with other users. Entries
are themselves assigned to a wrapper object called a ContentProfile which maintains a users unique collection.
ContentProfiles are the anchor back to the UserProfile, via the :person_authentication_key(PAK) or UUID they rely on as the primary identifier.
The ContentProfile collection of classes represent the database implementation of this Content Profile strategy.
The AccessProfile collection of classes represent the XML-File implementation of this Content Profile strategy as an extension to it's original role as access authorization for page views, clickables, and process access permissions.
## Installation
Application UserIDs are in the db/seed.rb file. Developer credentials are: username: developer, passwd: developer99
You will need to install PostGreSQL, and add/edit PostgreSQL credentials an the Application-Context Configuration YAML files:
config/settings.yml,
config/settings/development.yml or create and edit config/settings/development.local.yml
config/settings/test.yml or create and edit config/settings/test.local.yml
It might be helpful to set these environment params too:
export COVERAGE=true
export BUNDLE_PATH='vendor/bundle' Note: use of rvm wipes out all these values, you may need to reset them
note: demo userids are documented in the seeds.rb file.
Then execute;
```Bash
$ mkdir tmp
$ bin/setup
$ rspec
$ bundle exec rails server Puma -b 0.0.0.0
```
Also: db/seeds.rb contains test user credentials
lib/tasks/profile_tools_task.rake creates the initial database version of the content profile, during 'bin/setup'
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## License

Copyright (c) 2015-2016 James Scott, Jr.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

react-starter-kit
Inertia Rails React Starter Kit
Rails · 启动器

rails-tabler-starter
Free and open source Ruby on Rails starter kit built using Tabler
Rails · 后台

plutonium-core
Build production-ready Rails apps in minutes, not days. Convention-driven, fully customizable, AI-ready.
Rails · 后台

ace-template
Rails 8+ app template. Go from 0 to full-featured deployed app in less than 5 minutes (self-hosted or PaaS)
Rails · 启动器

kern
SaaS starter for Rails apps. Skip the boilerplate and start shipping the actual product.
Rails · SaaS

rails-react-starter
Simple React & Rails starter
Rails · 启动器
