百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
H

hypershield

> 编程语言
开源

在 Postgres 和 MySQL 中保护敏感数据

316 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

在 Postgres 和 MySQL 中保护敏感数据

Hypershield

:zap: Shield sensitive data in Postgres and MySQL

Great for business intelligence tools like Blazer

How It Works

Hypershield creates shielded views (in the hypershield schema by default) that hide sensitive tables and columns. The advantage of this approach over column-level privileges is you can use SELECT *.

By default, it hides columns with:

  • encrypted
  • password
  • token
  • secret

Give database users access to these views instead of the original tables.

Installation

Add this line to your application’s Gemfile:

ruby
gem "hypershield"

And run:

bash
rails generate hypershield:install

Hypershield is disabled in non-production environments by default. You can do a dry run with:

bash
rake hypershield:refresh:dry_run

Next, set up your production database.

  • Postgres
  • MySQL

When that’s done, deploy to production and run:

bash
rails db:migrate

The schema will automatically refresh.

Database Setup

Postgres

Create a new schema in your database

sql
CREATE SCHEMA hypershield;

Grant privileges

sql
GRANT USAGE ON SCHEMA hypershield TO myuser;

-- replace migrations with the user who manages your schema
ALTER DEFAULT PRIVILEGES FOR ROLE migrations IN SCHEMA hypershield
    GRANT SELECT ON TABLES TO myuser;

-- keep public in search path for functions
ALTER ROLE myuser SET search_path TO hypershield, public;

And connect as the user and make sure there’s no access the original tables

sql
SELECT * FROM public.users LIMIT 1;

MySQL

Create a new schema in your database

sql
CREATE SCHEMA hypershield;

Grant privileges

sql
GRANT SELECT, SHOW VIEW ON hypershield.* TO myuser;
FLUSH PRIVILEGES;

And connect as the user and make sure there’s no access the original tables

sql
SELECT * FROM mydb.users LIMIT 1;

Configuration

Set configuration in config/initializers/hypershield.rb.

Specify the schema to use and columns to show and hide

ruby
Hypershield.schemas = {
  hypershield: {
    hide: ["encrypted", "password", "token", "secret"],
    show: ["ahoy_visits.visitor_token", "ahoy_visits.visit_token"]
  }
}

Log Hypershield SQL statements

ruby
Hypershield.log_sql = true

Enable or disable Hypershield in an environment

ruby
Hypershield.enabled = Rails.env.production?

Include materialized views for Postgres

ruby
Hypershield.materialized_views = true

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

  • Report bugs
  • Fix bugs and submit pull requests
  • Write, clarify, or fix documentation
  • Suggest or add new features

To get started with development:

bash
git clone https://github.com/ankane/hypershield.git
cd hypershield
bundle install

# Postgres
createdb hypershield_test
bundle exec rake test

# MySQL
mysqladmin create hypershield_test
ADAPTER=mysql2 bundle exec rake test

Issues· 1 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言