Skip to content

Commit 16351aa

Browse files
committed
Update README and Actions workflows
Update README. Don't build on irrelevant changes, add publish to github packages, configure workflow permissions.
1 parent c737f8a commit 16351aa

3 files changed

Lines changed: 52 additions & 25 deletions

File tree

.github/workflows/main.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
name: Ruby
1+
name: Build
22

33
on:
44
push:
55
branches:
66
- master
7-
7+
paths-ignore:
8+
- '.**'
9+
- 'LICENSE'
10+
- 'ACKNOWLEDGEMENTS'
11+
- '**.md'
12+
- '**.txt'
13+
- '**.yml'
814
pull_request:
15+
paths-ignore:
16+
- '.**'
17+
- 'LICENSE'
18+
- 'ACKNOWLEDGEMENTS'
19+
- '**.md'
20+
- '**.txt'
21+
- '**.yml'
922

1023
jobs:
1124
build:

.github/workflows/release.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1-
name: publish
1+
name: Publish
22

33
on:
44
release:
55
types: [published]
66

7+
permissions:
8+
actions: read
9+
contents: read
10+
checks: read
11+
packages: write
12+
statuses: write
13+
714
jobs:
8-
setup:
9-
name: Set Up Environment
15+
publish-ghp:
16+
name: Publish Gem to GitHub Packages
1017
runs-on: ubuntu-latest
1118
steps:
1219
- uses: actions/checkout@v2
1320
- uses: ruby/setup-ruby@v1
1421
with:
22+
ruby-version: "3.2.0"
1523
bundler-cache: true
1624
- run: bundle install
17-
18-
publish-ghp:
19-
needs: [setup]
20-
name: Publish Gem
21-
runs-on: ubuntu-latest
22-
steps:
23-
- name: Publish
24-
shell: bash
25+
- shell: bash
2526
run: |
2627
set +x
2728
mkdir -p ~/.gem
2829
cat << EOF > ~/.gem/credentials
2930
---
30-
:github: Bearer ${{ GITHUB_TOKEN }}
31-
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
31+
:github: Bearer ${{ secrets.GITHUB_TOKEN }}
32+
:rubygems: ${{ secrets.RUBYGEMS_API_KEY }}
3233
EOF
3334
3435
chmod 0600 ~/.gem/credentials
3536
set -x
3637
3738
bundle exec gem build *.gemspec
38-
bundle exec gem push --key github --host "https://rubygems.pkg.github.com/chtzvt"
39-
bundle exec gem push --key rubygems_api_key --host "https://rubygems.org"
39+
bundle exec gem push *.gem --key github --host "https://rubygems.pkg.github.com/chtzvt"
40+
# bundle exec gem push *.gem --key rubygems --host "https://rubygems.org" - Need to work out OTP codes

README.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# Sssecrets
22

3-
Welcome to sssecrets: **S**imple **S**tructured **Secrets**.
3+
[![Gem Version](https://badge.fury.io/rb/sssecrets.svg)](https://badge.fury.io/rb/sssecrets) [![RubyDoc](https://img.shields.io/static/v1?url=https%3A%2F%2Frubydoc.info%2Fgems%2Fsssecrets&label=RubyDoc&message=sssecrets&color=informational)](https://rubydoc.info/gems/sssecrets) [![Build](https://github.com/chtzvt/sssecrets/actions/workflows/main.yml/badge.svg)](https://github.com/chtzvt/sssecrets/actions/workflows/main.yml) [![Publish](https://github.com/chtzvt/sssecrets/actions/workflows/release.yml/badge.svg)](https://github.com/chtzvt/sssecrets/actions/workflows/release.yml)
44

5-
Sssecrets is a reusable implementation of GitHub's structured secret token format. You can learn more about GitHub's design process and the properties of their API token format on the [GitHub blog](https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/).
65

7-
## Why Structured Secrets?
6+
Welcome to sssecrets: **S**imple **S**tructured **Secrets**. Sssecrets is a library for generating secrets (like API tokens, etc) in line with best practices.
87

9-
If you're a developer and your application issues some kind of access tokens (API keys, PATs, etc), it's important to format these in a way that both identifies the string as a secret token and provides insight into its permissions. Even better if you provide example (dummy) tokens and regexes for them in your documentation!
8+
Sssecrets is a reusable implementation of GitHub's [API token format](https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/) (which is also used by [NPM](https://github.blog/2021-09-23-announcing-npms-new-access-token-format/)), and it's designed to make it simple for developers to issue secure secret tokens that are easy to detect when leaked.
9+
10+
You can learn more about GitHub's design process and the properties of this API token format on the [GitHub blog](https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/).
11+
12+
## Why Structured Secrets?
13+
14+
If you're a developer and your application issues some kind of access tokens (API keys, PATs, etc), it's important to format these in a way that both identifies the string as a secret token and provides insight into its permissions. For bonus points, you should also provide example (dummy) tokens and regexes for them in your documentation.
1015

1116
Simple Structured Secrets help solve this problem: They're a compact format with properties that are optimized for detection with static analysis tools. That makes it possible to automatically detect when secrets are leaked in a codebase using features like [GitHub Secret Scanning](https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning) or GitLab Secret Detection.
1217

@@ -22,14 +27,20 @@ While random, strings in this format are used in many places for non-sensitive p
2227

2328
Structured secrets have three parts:
2429

25-
- A prefix (defined by you),
26-
- 30 characters of randomness,
27-
- A 6 character checksum.
30+
- A prefix (2-10 characters, defined by you)
31+
- 30 characters of randomness
32+
- A 6 character checksum
33+
34+
That's it!
2835

29-
That's it!
36+
Here's the format:
3037

3138
`[prefix]_[randomness][checksum]`
3239

40+
An example Sssecret, with an `org` of `t` and a `type` of `k`, looks like this:
41+
42+
`tk_GNrRoBa1p9nuwm7XrWkrhYUNQ7edOw4GUp8I`
43+
3344
### Prefix
3445

3546
Token prefixes are a simple and effective method to make tokens identifiable. [Slack](https://api.slack.com/authentication/token-types), [Stripe](https://stripe.com/docs/api/authentication), [GitHub](https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/#identifiable-prefixes), and others have adopted this approach to great effect.
@@ -52,6 +63,8 @@ The token checksum can be used as a first-pass validity check. Using these check
5263

5364
_Note that this library can only check whether a given token is in the correct form and has a valid checksum. To fully determine whether a given token is active, you'll still need to implement your own logic for checking the validity of tokens you've issued._
5465

66+
_Another note: Because Sssecrets uses the same format as GitHub tokens, you can also perform offline validation of GitHub-issued secrets with `SimpleStructuredSecrets#validate`._
67+
5568
## Installation
5669

5770
Add this gem to your application's Gemfile:

0 commit comments

Comments
 (0)