Skip to content

Commit

Permalink
Merge pull request #67 from carverauto/updates/ory_api
Browse files Browse the repository at this point in the history
Updates/ory api
  • Loading branch information
mfreeman451 authored Nov 25, 2024
2 parents 879289f + b7cf194 commit 1ed6724
Show file tree
Hide file tree
Showing 26 changed files with 71 additions and 455 deletions.
6 changes: 0 additions & 6 deletions cmd/api-admin/.ko.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions cmd/api-admin/Dockerfile

This file was deleted.

22 changes: 0 additions & 22 deletions cmd/api-admin/Makefile

This file was deleted.

13 changes: 0 additions & 13 deletions cmd/api-admin/configs/.env

This file was deleted.

87 changes: 0 additions & 87 deletions cmd/api-admin/main.go

This file was deleted.

3 changes: 0 additions & 3 deletions cmd/api-admin/superuser.json

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/api/configs/.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ HTTP_PORT=8200

LOG_LEVEL=DEBUG

JWKS_SERVER=https://affectionate-brattain-fl0yahcycw.projects.oryapis.com/.well-known/jwks.json
DSN=mongodb://er-mongodb.mongo.svc.cluster.local:27017
ORY_SDK_URL=http://hydra-admin.auth:4445
ORY_SCHEMA_ID=
DB_HOST=localhost
DB_USER=root
Expand Down
3 changes: 2 additions & 1 deletion cmd/api/configs/.staging.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ HTTP_PORT=8200
LOG_LEVEL=DEBUG

ORY_PROJECT_URL=http://localhost:4455
DB_URL=mongodb://mongodb.svc.cluster.local:27017
DB_URL=mongodb://er-mongodb.mongo.svc.cluster.local:27017
DSN=mongodb://er-mongodb.mongo.svc.cluster.local:27017
DB_NAME=eventrunner
16 changes: 13 additions & 3 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package main

import (
"context"
"os"
"time"

"github.com/carverauto/eventrunner/pkg/api/handlers"
Expand Down Expand Up @@ -38,8 +37,8 @@ func main() {

// Initialize Ory client
oryClient := ory.NewConfiguration()
oryClient.Servers = ory.ServerConfigurations{{URL: os.Getenv("ORY_SDK_URL")}}
// oryClient.DefaultHeader["Authorization"] = "Bearer " + os.Getenv("ORY_PAT")

oryClient.Servers = ory.ServerConfigurations{{URL: "http://hydra-admin.auth:4445"}}

apiClient := ory.NewAPIClient(oryClient)

Expand All @@ -61,6 +60,17 @@ func main() {
// Add other middleware and routes
app.UseMiddleware(middleware.CustomHeadersMiddleware())

// API Credentials routes
app.POST("/api/admin/credentials", middleware.Adapt(
h.CreateAPICredential,
middleware.RequireUser,
))

app.GET("/api/admin/credentials", middleware.Adapt(
h.ListAPICredentials,
middleware.RequireUser,
))

// this endpoint is used by the Ory Kratos login flow
app.GET("/callback", func(ctx *gofr.Context) (interface{}, error) {
code := ctx.Request.Param("code")
Expand Down
23 changes: 22 additions & 1 deletion docs/auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ EventRunner uses Ory's identity stack for authentication:
- Hydra: OAuth2 provider
- Oathkeeper: API gateway and access control

## Flow Diagram
## Flow Diagrams

### Overview

```mermaid
sequenceDiagram
Expand Down Expand Up @@ -46,6 +48,25 @@ sequenceDiagram
Hydra-->>Oathkeeper: Token valid + claims
Oathkeeper->>API: Request + X-headers
```
### User Registration Flow

```mermaid
sequenceDiagram
participant Client
participant Hydra
participant Kratos
Client->>Hydra: POST /oauth2/register
Note over Client,Hydra: Sends metadata, redirect URIs, etc.
Hydra->>Hydra: Validates request
Hydra-->>Client: Returns client_id, client_secret
Note over Client,Hydra: Also returns registration_access_token
Note over Client,Hydra: Later...
Client->>Hydra: GET /oauth2/register/{client_id}
Note over Client,Hydra: Uses registration_access_token
Hydra-->>Client: Returns client config
```

## Step-by-Step Guide

Expand Down
49 changes: 0 additions & 49 deletions k8s/api-admin/base/api-admin.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions k8s/api-admin/base/configmap.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions k8s/api-admin/base/db-creds.yaml

This file was deleted.

Loading

0 comments on commit 1ed6724

Please sign in to comment.