Skip to content

Commit d2842c3

Browse files
committed
Updates
1 parent 31b77a9 commit d2842c3

File tree

6 files changed

+102
-45
lines changed

6 files changed

+102
-45
lines changed

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ WORKDIR /opt/app
44
COPY . /opt/app
55
RUN shards install
66
RUN crystal build --release --static ./src/server.cr -o ./server
7+
RUN crystal build --release --static ./taskfile.cr -o ./azu
78
CMD ["crystal", "spec"]
89

910
FROM alpine:latest
1011
RUN apk --no-cache add ca-certificates
1112
WORKDIR /root/
1213
COPY --from=0 /opt/app/server .
14+
COPY --from=0 /opt/app/azu .
1315
COPY --from=0 /opt/app/public ./public
1416
CMD ["./server"]

README.md

+76-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<div style="text-align:center"><img src="https://raw.githubusercontent.com/azutoolkit/authority/main/logo.png" /></div>
1+
<div style="text-align:center"><img src="https://github.com/azutoolkit/authority/blob/main/logo.png"></div>
22

3-
# authority
3+
# Authority
44

55
OpenID Connect and OAuth Provider written in Crystal - Security-first, open
66
source API security for your infrastructure. SDKs to come.
@@ -13,70 +13,104 @@ Implementing and using OAuth2 without understanding the whole specification is
1313
challenging and prone to errors, even when SDKs are being used. The primary goal
1414
of Authority is to make OAuth 2.0 and OpenID Connect 1.0 better accessible.
1515

16-
## Installation
16+
The specification describes five grants for acquiring an access token:
1717

18-
TODO: Write installation instructions here
18+
- Authorization code grant
19+
- Implicit grant
20+
- Resource owner credentials grant
21+
- Client credentials grant
22+
- Refresh token grant
1923

20-
## Usage
24+
## JSON Web Tokens
2125

22-
TODO: Write usage instructions here
26+
At this moment Authority issues JWT OAuth 2.0 Access Tokens as default.
2327

24-
## Features Missing
28+
## Features
2529

26-
Token Information Endpoint
30+
Grant Types
2731

28-
```bash
29-
POST /token_info HTTP/1.1
30-
Host: authorization-server.com
31-
Authorization: Basic Y4NmE4MzFhZGFkNzU2YWRhN
32+
- [x] Authorization code grant
33+
- [x] Implicit grant
34+
- [x] Resource owner credentials grant
35+
- [x] Client credentials grant
36+
- [x] Refresh token grant
37+
- [x] OpenID Connect
38+
- [x] PKCE
39+
- [ ] Token Introspection
40+
- [ ] Token Revocation
3241

33-
token=c1MGYwNDJiYmYxNDFkZjVkOGI0MSAgLQ
34-
```
42+
## Configuration
3543

36-
```bash
37-
HTTP/1.1 200 OK
38-
Content-Type: application/json; charset=utf-8
39-
40-
{
41-
"active": true,
42-
"scope": "read write email",
43-
"client_id": "J8NFmU4tJVgDxKaJFmXTWvaHO",
44-
"username": "aaronpk",
45-
"exp": 1437275311
46-
}
44+
Configuration files can be found in `./src/config`
45+
46+
### Authly.cr
47+
48+
This file contains the configuration for the OAuthly 2 library. Read more about [Authly shards](https://github.com/azutoolkit/authly)
49+
50+
```crystal
51+
# Configure
52+
Authly.configure do |c|
53+
# Secret Key for JWT Tokens
54+
c.secret_key = "ExampleSecretKey"
55+
56+
# Refresh Token Time To Live
57+
c.refresh_ttl = 1.hour
58+
59+
# Authorization Code Time To Live
60+
c.code_ttl = 1.hour
61+
62+
# Access Token Time To Live
63+
c.access_ttl = 1.hour
64+
65+
# Using your own classes
66+
c.owners = Authority::OwnerService.new
67+
c.clients = Authority::ClientService.new
68+
end
4769
```
4870

49-
ID Tokens
71+
### Clear.cr
72+
73+
This file contains the database configuration. No changes to this files is required.
74+
75+
### Local.env
76+
77+
This file contains the environment variables for Authority.
5078

5179
```bash
52-
{
53-
"iss": "https://server.example.com",
54-
"sub": "24400320",
55-
"aud": "s6BhdRkqt3",
56-
"nonce": "n-0S6_WzA2Mj",
57-
"exp": 1311281970,
58-
"iat": 1311280970,
59-
"auth_time": 1311280969,
60-
"acr": "urn:mace:incommon:iap:silver"
61-
}
80+
CRYSTAL_ENV=development
81+
CRYSTAL_LOG_SOURCES="*"
82+
CRYSTAL_LOG_LEVEL="debug"
83+
CRYSTAL_WORKERS=4
84+
PORT=4000
85+
PORT_REUSE=true
86+
HOST=0.0.0.0
87+
DATABASE_URL=postgres://auth_user:auth_pass@db:5432/authority_db
6288
```
6389

64-
User Registration
90+
## HTML Templates
91+
92+
You can change the look of Authority `signin` and `authorize` html pages.
6593

66-
Client Registration
94+
Just edit the `./public/templates/signin.html` and `./public/templates/authorize.html`
6795

68-
## Development
96+
## Installation
97+
98+
### Docker Compose
99+
100+
Spin up your server
69101

70-
TODO: Write development instructions here
102+
```bash
103+
docker-compose up server
104+
```
71105

72106
## Contributing
73107

74-
1. Fork it (<https://github.com/your-github-user/authority/fork>)
108+
1. Fork it (https://github.com/azutoolkit/authority/fork)
75109
2. Create your feature branch (`git checkout -b my-new-feature`)
76110
3. Commit your changes (`git commit -am 'Add some feature'`)
77111
4. Push to the branch (`git push origin my-new-feature`)
78112
5. Create a new Pull Request
79113

80114
## Contributors
81115

82-
- [Elias Perez](https://github.com/your-github-user) - creator and maintainer
116+
- [Elias Perez](https://github.com/eliasjpr) - creator and maintainer

docker-compose.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,29 @@ services:
1010
ports:
1111
- 5432:5432
1212

13+
migrator:
14+
build:
15+
context: .
16+
dockerfile: migrate.Dockerfile
17+
container_name: migrator
18+
working_dir: /root/
19+
env_file:
20+
- local.env
21+
ports:
22+
- "4000:4000"
23+
depends_on:
24+
- db
25+
1326
server:
1427
build:
1528
context: .
1629
dockerfile: Dockerfile
1730
command: ./server
18-
container_name: web
31+
container_name: authority
1932
working_dir: /root/
2033
env_file:
2134
- local.env
2235
ports:
2336
- "4000:4000"
2437
depends_on:
25-
- db
38+
- migrator

local.env

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ CRYSTAL_WORKERS=4
55
PORT=4000
66
PORT_REUSE=true
77
HOST=0.0.0.0
8-
DATABASE_URL=postgres://auth_user:auth_pass@localhost:5432/authority_db
8+
DATABASE_URL=postgres://auth_user:auth_pass@db:5432/authority_db

migrate.Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
FROM crystallang/crystal:latest-alpine
3+
WORKDIR /opt/app
4+
COPY . /opt/app
5+
RUN shards install
6+
RUN crystal build --release --static ./taskfile.cr -o ./azu
7+
CMD ["./azu", "db", "migrate"]

src/server.cr

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "./authority"
2+
23
# Start your server
34
# Add Handlers to your App Server
45
Authority.start [

0 commit comments

Comments
 (0)