Table of contents
Open Table of contents
Auth Server
Authentication/Authorization microservice written in Go, which provides gRPC endpoints (schemas can be found here) for managing JWT tokens and user’s data. The data is stored in a PostgreSQL and data integrity is maintained through the use of migrations.
Source code can be found on GitHub.
Running Locally
- To run the server and PostgreSQL locally you can execute:
make run
- To stop them, run:
make down
- Alternatively you can start the database and apply migrations by running:
make run-postgres DETACHED=true && make migrate
- And then start a server:
go run cmd/sso/main.go --config=./configs/local.yaml
- API will be available at http://localhost:8080/
How to Connect From Another Service
- Fetch schemas from the auth-server-schemas repo:
go get github.com/martishin/auth-server-schemas
- Create a client connection:
cc, err := grpc.DialContext(context.Background(),
net.JoinHostPort(grpcHost, grpcPort),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
- Initialize a client:
authClient := ssov1.NewAuthClient(cc)
- Make requests using the client:
resp, err := authClient.Register(ctx, &ssov1.RegisterRequest{
Email: email,
Password: password,
})
- Usage examples can be found in e2e tests
Endpoints
gRPC protobuf schemas can be found here. You can import the schema file into Postman and send requests from it.
Auth / Register
Registers a new user.
-
Request:
RegisterRequest
email
(string): User’s email address.password
(string): User’s password.
-
Response:
RegisterResponse
user_id
(int64): Unique identifier of the registered user.
Auth / Login
Authenticates a user and provides a token.
-
Request:
LoginRequest
email
(string): User’s email address.password
(string): User’s password.app_id
(int32): Application identifier.
-
Response:
LoginResponse
token
(string): Authentication token for the user.
Auth / IsAdmin
Checks if the user is an admin.
-
Request:
IsAdminRequest
user_id
(int64): Unique identifier of the user.
-
Response:
IsAdminResponse
is_admin
(bool): Indicates whether the user is an admin.