Skip to content

Commit f57820b

Browse files
authored
Merge pull request #5 from reugn/develop
v0.4.0
2 parents bb520e3 + c058c60 commit f57820b

Some content is hidden

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

53 files changed

+1681
-904
lines changed

.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
.github
33
.cache
44

5-
examples/
5+
examples/
6+
docs/

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
go-version: [1.21.x]
1717
steps:
1818
- name: Setup Go
19-
uses: actions/setup-go@v4
19+
uses: actions/setup-go@v5
2020
with:
2121
go-version: ${{ matrix.go-version }}
2222

2323
- name: Checkout code
24-
uses: actions/checkout@v3
24+
uses: actions/checkout@v4
2525

2626
- name: Test
27-
run: go test ./...
27+
run: go test ./...

.github/workflows/docker.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout repository
21-
uses: actions/checkout@v3
21+
uses: actions/checkout@v4
2222

2323
- name: Log in to the Container registry
2424
uses: docker/login-action@v2

.github/workflows/golangci-lint.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: golangci-lint
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
golangci:
14+
name: lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: '1.22'
23+
cache: false
24+
25+
- name: golangci-lint
26+
uses: golangci/golangci-lint-action@v4
27+
with:
28+
version: v1.56

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
/vendor
44
/secrets/cert.pem
55
/secrets/privkey.pem
6-
auth-server
6+
/cmd/auth/auth

.golangci.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
linters:
2+
disable-all: true
3+
enable:
4+
- dupl
5+
- errcheck
6+
- errorlint
7+
- exportloopref
8+
- funlen
9+
- gci
10+
- goconst
11+
- gocritic
12+
- gocyclo
13+
- gofmt
14+
- goimports
15+
- gosimple
16+
- govet
17+
- ineffassign
18+
- lll
19+
- misspell
20+
- prealloc
21+
- revive
22+
- staticcheck
23+
- stylecheck
24+
- typecheck
25+
- unconvert
26+
- unparam
27+
- unused
28+
29+
issues:
30+
exclude-rules:
31+
- path: _test\.go
32+
linters:
33+
- unparam
34+
- funlen

Dockerfile

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
FROM golang:alpine AS build
1+
# syntax=docker/dockerfile:1.2
2+
FROM golang:alpine3.19 AS build
23
RUN apk --no-cache add gcc g++ make git
34
WORKDIR /go/src/app
45
COPY . .
56
RUN go get ./...
7+
WORKDIR /go/src/app/cmd/auth
68
RUN GOOS=linux go build -ldflags="-s -w" -o ./bin/auth
79

8-
FROM alpine:3.14
9-
WORKDIR /go/bin
10-
COPY --from=build /go/src/app/bin /go/bin
10+
FROM alpine:3.19.1
11+
WORKDIR /app
12+
COPY --from=build /go/src/app/cmd/auth/bin /app
13+
COPY --from=build /go/src/app/config /app/
1114
COPY ./secrets ./secrets
15+
ENV AUTH_SERVER_LOCAL_CONFIG_PATH=local_repository_config.yml
16+
1217
EXPOSE 8081
13-
ENTRYPOINT ["/go/bin/auth"]
18+
ENTRYPOINT ["/app/auth", "-c", "service_config.yml"]

README.md

+26-15
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33
[![PkgGoDev](https://pkg.go.dev/badge/github.com/reugn/auth-server)](https://pkg.go.dev/github.com/reugn/auth-server)
44
[![Go Report Card](https://goreportcard.com/badge/github.com/reugn/auth-server)](https://goreportcard.com/report/github.com/reugn/auth-server)
55

6-
This project provides tools to set up a custom authentication and authorization server.
7-
`auth-server` can act as a proxy middleware or be configured in a stand-alone mode. It doesn't require any third-party software integration. Use one of the [available repositories](./repository) to configure backend storage, or implement one of your own.
6+
This project offers a toolkit for building and configuring a tailored authentication and authorization service.
87

9-
**Note:** This project has not yet passed security testing. Make sure you know what you are doing when setting up your own OAuth2 provider.
8+
`auth-server` can act as a proxy middleware or be configured in a stand-alone mode. It doesn't require any third-party software integration.
9+
Leverage existing backend [storage repositories](internal/repository) for storing security policies or develop a custom one to suit your specific requirements.
10+
For information on how to configure repositories using environment variables, refer to the [repository configuration](docs/repository_configuration.md) page.
11+
12+
> [!NOTE]
13+
> This project's security has not been thoroughly evaluated. Proceed with caution when setting up your own auth provider.
1014
1115
## Introduction
1216
* **Authentication** is used by a server when the server needs to know exactly who is accessing their information or site.
1317
* **Authorization** is a process by which a server determines if the client has permission to use a resource or access a file.
1418

15-
Creating an authentication and authorization strategy is always a complex process. A number of quick questions immediately arise:
19+
The inherent complexity of crafting an authentication and authorization strategy raises a barrage of immediate questions:
1620

17-
* Should we set up separate services for authentication and authorization
18-
* How do we handle access token creation and who is responsible for this
19-
* Should we alter our REST service to support authorization flow
21+
* Would it be beneficial to utilize separate services for authentication and authorization purposes?
22+
* What is the process for creating access tokens, and who is tasked with this responsibility?
23+
* Is it necessary to adapt our REST service to support an authorization flow?
2024

21-
The `auth-server` project tries to accumulate all of those capabilities and act as a transparent authentication and authorization proxy middleware.
25+
The `auth-server` project aims to address these concerns by serving as a transparent authentication and authorization proxy middleware.
2226

2327
## Architecture
24-
![architecture_diagram](./images/architecture_diagram_1.png)
28+
![architecture_diagram](docs/images/architecture_diagram_1.png)
2529

2630
1. The user requests an access token (JWT), using a basic authentication header:
2731
```
@@ -45,20 +49,27 @@ The `auth-server` project tries to accumulate all of those capabilities and act
4549
4650
## Installation and Prerequisites
4751
* `auth-server` is written in Golang.
48-
To install the latest stable version of Go, visit https://golang.org/dl/
52+
To install the latest stable version of Go, visit the [releases page](https://golang.org/dl/).
53+
54+
* Read the following [instructions](./secrets/README.md) to generate keys required to sign the token. Specify the location of the generated certificates in the service configuration file. An example of the configuration file can be found [here](config/service_config.yml).
55+
56+
* The following example shows how to run the service using a configuration file:
57+
```
58+
./auth -c service_config.yml
59+
```
4960
5061
* To run the project using Docker, visit their [page](https://www.docker.com/get-started) to get started. Docker images are available under the [GitHub Packages](https://github.com/reugn/auth-server/packages).
5162
5263
* Install `docker-compose` to get started with the examples.
5364
54-
* Read the following [instructions](./secrets/README.md) to generate keys.
55-
5665
## Examples
57-
Examples are available under the examples folder.
66+
Examples are available under the [examples](examples) folder.
5867
5968
To run `auth-server` as a [Traefik](https://docs.traefik.io/) middleware:
60-
* `cd examples/traefik`
61-
* `docker-compose up -d`
69+
```
70+
cd examples/traefik
71+
docker-compose up -d
72+
```
6273
6374
## License
6475
Licensed under the Apache 2.0 License.

auth/env.go

-40
This file was deleted.

auth/jwt_generator.go

-51
This file was deleted.

auth/jwt_validator.go

-75
This file was deleted.

0 commit comments

Comments
 (0)