Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump sea-orm-codegen from 0.12.14 to 0.12.15 #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
- ../policy/:/policy:cached,z
env_file: opa.env
environment:
JWKS_ENDPOINT: https://authn.diamond.ac.uk/realms/master/protocol/openid-connect/certs
SKIP_AUTHORIZATION: true

ispyb:
image: ghcr.io/diamondlightsource/ispyb-database:v3.0.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ prettyplease = "0.2.16"
sea-orm = { workspace = true }

[build-dependencies]
sea-orm-codegen = { version = "0.12.14" }
sea-orm-codegen = { version = "0.12.15" }
sea-schema = { version = "0.14.2", default-features = false, features = [
"runtime-tokio-rustls",
"sqlx-mysql",
Expand Down
19 changes: 18 additions & 1 deletion policy/system.rego
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
package system

import data.token.claims
import rego.v1

main := {"allow": allow}

default allow := false

# Allow if the SKIP_AUTHORIZATION environment variable is set and a preset token is supplied
allow if {
input.token == "ValidToken"
opa.runtime().env.SKIP_AUTHORIZATION
input.token == "ValidToken"
}

# Allow if on proposal which contains session
allow if {
some proposal_number in data.diamond.data.subjects[claims.fedid].proposals
proposal_number == input.proposal
}

# Allow if directly on session
allow if {
some session_id in data.diamond.data.subjects[claims.fedid].sessions
session := data.diamond.data.sessions[session_id]
session.proposal_number == input.proposal
session.visit_number == input.visit
}
26 changes: 26 additions & 0 deletions policy/token.rego
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package token

fetch_jwks(url) := http.send({
"url": jwks_url,
"method": "GET",
"force_cache": true,
"force_cache_duration_seconds": 3600,
})

jwks_endpoint := opa.runtime().env.JWKS_ENDPOINT

token_unverified := io.jwt.decode(input.token)

token_jwt_header := token_unverified[0]

jwks_url := concat("?", [jwks_endpoint, urlquery.encode_object({"kid": token_jwt_header.kid})])

jwks := fetch_jwks(jwks_url).raw_body

token := token_unverified

if {
io.jwt.verify_rs256(input.token, jwks)
}

claims := token[1]
Loading