Skip to content

Commit 3d70e77

Browse files
authored
Client metadata (#57)
* Aligning `clients.yml` with OAuth terminology using the keys specified in RFC 7591 * Proper Client Authentication * Show client information on the consent page * Necessary Client Authentication Methods, Code refactoring, Better Tests * Adapted Metadata * Fixes * Further Bugfixes * Rubocop * Respect `response_mode` in error responses (#54) * Keep track of metadata during auth flows This addresses issue #55 * Relocate jwks.json It is not a .well-known endpoint * OIDC RP-initiated Logout * Build Server changes * Test scripts run with `bundle` * Fix: User now added to authorization cache * "If You Want Them to RTFM, Make a Better FM" Let's give it a try * Uniform rules for scope checks for all auth grants * Removed unspecified parameters at token endpoint during code flow * Fixed default client auth method * Selfmade CORS * Removed `allowed_origin` configuration option * Fix pipeline * Refactoring and dependency management * Updated main README * Documentation Updates and Fixes * Minor Bugfixes * Default configuration
1 parent e0c6d4f commit 3d70e77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1982
-1121
lines changed

.github/workflows/build-server.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,8 @@ jobs:
2525
rubocop
2626
- name: Unit tests
2727
run: |
28-
gem install --no-document test-unit rack-test webrick
29-
bundle exec ruby tests/test_admin_api.rb
30-
bundle exec ruby tests/test_selfservice_api.rb
31-
bundle exec ruby tests/test_oauth_helper.rb
32-
bundle exec ruby tests/test_oauth2.rb
33-
bundle exec ruby tests/test_jwks.rb
28+
gem install --no-document test-unit rack-test
29+
scripts/test_all.sh
3430
- name: SBOM generation
3531
run: |
3632
gem install --no-document cyclonedx-ruby

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
!/keys/.gitkeep
44
/config/*
55
/omejdn_priv.*
6+
/.bundle

Gemfile

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
source 'https://rubygems.org'
44

5-
gem 'abstraction'
6-
gem 'bcrypt'
7-
gem 'haml'
8-
gem 'json'
9-
gem 'json-jwt'
10-
gem 'jwt'
11-
gem 'net-ldap'
12-
gem 'openssl'
13-
gem 'rack-test'
14-
gem 'require_all'
15-
gem 'rspec'
16-
gem 'scanf'
17-
gem 'sinatra'
18-
gem 'sinatra-activerecord'
19-
gem 'sinatra-contrib'
20-
gem 'sinatra-cors'
21-
gem 'sqlite3'
22-
gem 'test-unit'
23-
gem 'thin'
24-
gem 'webrick'
5+
# Necessary Gems for Core Omejdn
6+
group :omejdn do
7+
gem 'bcrypt'
8+
gem 'haml'
9+
gem 'jwt'
10+
gem 'openssl'
11+
gem 'sinatra'
12+
gem 'sinatra-contrib'
13+
gem 'thin'
14+
end
15+
16+
# Necessary Gems for Plugins
17+
group :plugins do
18+
gem 'net-ldap'
19+
gem 'sqlite3'
20+
end
21+
22+
# Development only
23+
group :development do
24+
gem 'rack-test'
25+
gem 'rubocop'
26+
gem 'test-unit'
27+
end

Gemfile.lock

Lines changed: 28 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,55 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
abstraction (0.0.4)
5-
activemodel (7.0.1)
6-
activesupport (= 7.0.1)
7-
activerecord (7.0.1)
8-
activemodel (= 7.0.1)
9-
activesupport (= 7.0.1)
10-
activesupport (7.0.1)
11-
concurrent-ruby (~> 1.0, >= 1.0.2)
12-
i18n (>= 1.6, < 2)
13-
minitest (>= 5.1)
14-
tzinfo (~> 2.0)
15-
aes_key_wrap (1.1.0)
16-
bcrypt (3.1.16)
17-
bindata (2.4.10)
18-
concurrent-ruby (1.1.9)
4+
ast (2.4.2)
5+
bcrypt (3.1.17)
196
daemons (1.4.1)
20-
diff-lcs (1.5.0)
217
eventmachine (1.2.7)
228
haml (5.2.2)
239
temple (>= 0.8.0)
2410
tilt
25-
i18n (1.9.1)
26-
concurrent-ruby (~> 1.0)
27-
json (2.6.1)
28-
json-jwt (1.13.0)
29-
activesupport (>= 4.2)
30-
aes_key_wrap
31-
bindata
3211
jwt (2.3.0)
33-
minitest (5.15.0)
3412
multi_json (1.15.0)
3513
mustermann (1.1.1)
3614
ruby2_keywords (~> 0.0.1)
3715
net-ldap (0.17.0)
3816
openssl (3.0.0)
17+
parallel (1.21.0)
18+
parser (3.1.1.0)
19+
ast (~> 2.4.1)
3920
power_assert (2.0.1)
4021
rack (2.2.3)
41-
rack-protection (2.1.0)
22+
rack-protection (2.2.0)
4223
rack
4324
rack-test (1.1.0)
4425
rack (>= 1.0, < 3)
45-
require_all (3.0.0)
46-
rspec (3.10.0)
47-
rspec-core (~> 3.10.0)
48-
rspec-expectations (~> 3.10.0)
49-
rspec-mocks (~> 3.10.0)
50-
rspec-core (3.10.2)
51-
rspec-support (~> 3.10.0)
52-
rspec-expectations (3.10.2)
53-
diff-lcs (>= 1.2.0, < 2.0)
54-
rspec-support (~> 3.10.0)
55-
rspec-mocks (3.10.3)
56-
diff-lcs (>= 1.2.0, < 2.0)
57-
rspec-support (~> 3.10.0)
58-
rspec-support (3.10.3)
26+
rainbow (3.1.1)
27+
regexp_parser (2.2.1)
28+
rexml (3.2.5)
29+
rubocop (1.26.0)
30+
parallel (~> 1.10)
31+
parser (>= 3.1.0.0)
32+
rainbow (>= 2.2.2, < 4.0)
33+
regexp_parser (>= 1.8, < 3.0)
34+
rexml
35+
rubocop-ast (>= 1.16.0, < 2.0)
36+
ruby-progressbar (~> 1.7)
37+
unicode-display_width (>= 1.4.0, < 3.0)
38+
rubocop-ast (1.16.0)
39+
parser (>= 3.1.1.0)
40+
ruby-progressbar (1.11.0)
5941
ruby2_keywords (0.0.5)
60-
scanf (1.0.0)
61-
sinatra (2.1.0)
42+
sinatra (2.2.0)
6243
mustermann (~> 1.0)
6344
rack (~> 2.2)
64-
rack-protection (= 2.1.0)
45+
rack-protection (= 2.2.0)
6546
tilt (~> 2.0)
66-
sinatra-activerecord (2.0.25)
67-
activerecord (>= 4.1)
68-
sinatra (>= 1.0)
69-
sinatra-contrib (2.1.0)
47+
sinatra-contrib (2.2.0)
7048
multi_json
7149
mustermann (~> 1.0)
72-
rack-protection (= 2.1.0)
73-
sinatra (= 2.1.0)
50+
rack-protection (= 2.2.0)
51+
sinatra (= 2.2.0)
7452
tilt (~> 2.0)
75-
sinatra-cors (1.2.0)
7653
sqlite3 (1.4.2)
7754
temple (0.8.2)
7855
test-unit (3.5.3)
@@ -82,34 +59,24 @@ GEM
8259
eventmachine (~> 1.0, >= 1.0.4)
8360
rack (>= 1, < 3)
8461
tilt (2.0.10)
85-
tzinfo (2.0.4)
86-
concurrent-ruby (~> 1.0)
87-
webrick (1.7.0)
62+
unicode-display_width (2.1.0)
8863

8964
PLATFORMS
9065
x86_64-linux
9166

9267
DEPENDENCIES
93-
abstraction
9468
bcrypt
9569
haml
96-
json
97-
json-jwt
9870
jwt
9971
net-ldap
10072
openssl
10173
rack-test
102-
require_all
103-
rspec
104-
scanf
74+
rubocop
10575
sinatra
106-
sinatra-activerecord
10776
sinatra-contrib
108-
sinatra-cors
10977
sqlite3
11078
test-unit
11179
thin
112-
webrick
11380

11481
BUNDLED WITH
11582
2.3.6

HACKING

Lines changed: 0 additions & 6 deletions
This file was deleted.

HACKING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Commit message format
2+
3+
Please try to use meaningful commit messages.
4+
5+
Think: "Would I understand what was changed when re-reading the commit message
6+
a few months in the future". If not, then maybe you want to be more verbose.
7+
8+
# Documentation
9+
10+
Pull Requests should aim to update the documentation alongside the code.
11+
If you do not feel like documenting, because it would take you too long,
12+
indicate so in your PR and someone else may be able to update the docs
13+
before the code is merged.

README.md

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
![Omejdn](public/img/logo.jpg)
66

7-
Omejdn is a minimal but extensible OAuth 2.0/OpenID connect server for ...
7+
Omejdn is a minimal but extensible OAuth 2.0/OpenID connect server used for ...
88

99
1. IoT devices which use their private keys to request OAuth2 access tokens in order to access protected resources
1010
1. Websites or apps which retrieve user attributes
@@ -16,16 +16,16 @@ Some of Omejdn's core features include:
1616

1717
* Database-free easy-to-read configuration files
1818
* Integration of existing LDAP directory services
19-
* Fully configurable through the Admin API Plugin (see API.md)
19+
* Fully configurable through the Admin API Plugin
2020
* A User Selfservice API Plugin
21+
* Standard Compliance (see below)
2122

2223

2324
**IMPORTANT**: Omejdn is meant to be a research sandbox in which we can
2425
(re)implement standard protocols and potentially extend and modify functionality
2526
under the hood to support research projects.
26-
It is **NOT** a production grade solution and should not be used as such.
27-
28-
Before updating, please take a look at `release_notes.md` to see if an update requires manual intervention.
27+
Use at your own risk!
28+
At a minimum, take a look at the documentation for production setups.
2929

3030
---
3131

@@ -44,6 +44,8 @@ Depending on your use case, you might want to at least configure the following o
4444
To start Omejdn, simply execute
4545

4646
```
47+
$ bundle config set --local with omejdn
48+
$ bundle config set --local without plugins development # Include these for more complex setups and development
4749
$ bundle install
4850
$ ruby omejdn.rb
4951
```
@@ -54,10 +56,11 @@ as advertised at `/.well-known/oauth-authorization-server`.
5456

5557
For testing purposes, a script for creating JWT Bearer Tokens for client authentication is located at `scripts/create_test_token.rb`.
5658

57-
**NOTE**: Omejdn does not come with its own TLS server and needs to be run behind a reverse proxy in production setups.
58-
5959
## Configuration
6060

61+
This section provides but a very brief overview of the possible configuration options.
62+
When in doubt, take a look at the documentation in `/docs`.
63+
6164
### Signing keys
6265

6366
The server public/private key pair used to sign tokens is located at `keys/omejdn/omejdn.key`.
@@ -67,31 +70,19 @@ You may place other keys and certificates in this folder to have the keys be adv
6770

6871
### Clients
6972

70-
Clients are configured in `config/clients.yml`.
71-
Have a look at the file to see the format.
72-
73-
Confidential clients need to authenticate using a JWT bearer.
74-
This requires placing a non-expired certificate at `keys/clients/$(base64urlencode(CLIENT_ID)).cert`.
75-
To have keys be automatically be copied to the correct position, you may specify `import_certfile` for that client in the client configuration file.
76-
Only confidential clients may use the `client_credentials` grant.
73+
Clients are configured in `config/clients.yml` using the client registration parameters.
74+
A minimal public client needs to have
7775

78-
In order to generate your own key pair with a self-signed pulic key
79-
for testing, your can execute:
80-
81-
$ openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem
76+
- a unique `client_id`
77+
- a `token_endpoint_auth_method` with a value of `none`
78+
- at least one value listed under `redirect_uris`
79+
- at least one value listed under `scope`
8280

8381
### Users
8482

8583
Users are configured using one or more *User Databases*, or `user_db` plugins.
86-
Which plugin you need to use depends on your setup, but here is a brief overview:
87-
88-
* `yaml` reads users from a YAML file (`config/users.yml` by default).
89-
This plugin is useful for semi-static, small sets of users, such as Admin-accounts.
90-
The configuration format is described in the docs.
91-
92-
* `sqlite` stores users and their attributes in a SQLite3 database. This is useful for larger local sets of users.
93-
94-
* `ldap` Connect to an existing LDAP directory. You will know when to use this.
84+
Simple setups will probably use the `yaml` plugin, which reads `config/users.yml` by default. Each user has a username, password, and an array of attributes.
85+
For more complex setups take a look at the documentation.
9586

9687
### Scopes and Attributes
9788

@@ -104,7 +95,7 @@ the `userinfo` endpoint response will also include this attribute.
10495
Have a look at the `attributes` claim mapper plugin.)
10596

10697
Scopes are granted if the subject contains at least one such attribute.
107-
Scopes of the form `k:v` are granted if the user contains an attribute with key `k` and value `v`.
98+
Scopes of the form `k:v` are granted if the user contains an attribute with key `k` and value `v`. See the documentation for details.
10899

109100
In `config/scope_description.yml` you can configure a short description string
110101
which is displayed to the user in an OpenID Connect flow upon requesting
@@ -121,7 +112,7 @@ There are some special scopes you may want to use:
121112
### Plugins
122113

123114
Omejdn's functionality can be customized through the use of plugins.
124-
For more information please take a look at [the Plugin README](plugins/README.md).
115+
For more information please take a look at the documentation.
125116

126117
## Using the Omejdn Docker Image
127118

@@ -156,6 +147,7 @@ This server mostly implements the following standards (potentially via plugins):
156147
* [RFC 9068](https://datatracker.ietf.org/doc/rfc9068/) - JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens
157148
* [RFC 9101](https://datatracker.ietf.org/doc/rfc9101/) - The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR)
158149
* [RFC 9126](https://datatracker.ietf.org/doc/rfc9126/) - OAuth 2.0 Pushed Authorization Requests
150+
* [RFC 9207](https://datatracker.ietf.org/doc/rfc9207/) - OAuth 2.0 Authorization Server Issuer Identification
159151
- OpenID Connect Protocol Suite
160152
* [OpenID Connect Core](https://openid.net/specs/openid-connect-core-1_0.html)
161153
* [OpenID Connect Discovery](https://openid.net/specs/openid-connect-discovery-1_0.html)
@@ -165,7 +157,7 @@ This server mostly implements the following standards (potentially via plugins):
165157
- Internet Drafts
166158
* [draft-spencer-oauth-claims-01](https://www.ietf.org/archive/id/draft-spencer-oauth-claims-01.txt)
167159
* [draft-ietf-oauth-security-topics-19](https://datatracker.ietf.org/doc/draft-ietf-oauth-security-topics/)
168-
* [draft-ietf-oauth-v2-1-04](https://datatracker.ietf.org/doc/draft-ietf-oauth-v2-1/)
160+
* [draft-ietf-oauth-v2-1-05](https://datatracker.ietf.org/doc/draft-ietf-oauth-v2-1/)
169161

170162

171163
**NOTE**: Omejdn only implements *two* grant types:
@@ -206,6 +198,7 @@ Omejdn uses the following directory structure:
206198
\_ clients/ (The public key certificates for clients)
207199
\_ views/ (Web-Pages)
208200
\_ public/ (Additional frontend resources (CSS+Images))
201+
\_ docs/ (Documentation)
209202
\_ tests/
210203
\_ test_*.rb (Unit and E2E tests for Omejdn)
211204
\_ test_resources/ (Test vectors)

0 commit comments

Comments
 (0)