summaryrefslogblamecommitdiff
path: root/includes/oathkeeper.jsonnet
blob: b396f3775d678bfc8df11edea82991ab89ea5559 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14













                                              
                                 







































                                                                       
local main = import "main.jsonnet";

local cookieSessionAuthenticator = {
  handler: "cookie_session"
};
local oauth2ClientCredentialsAuthenticator = {
  handler: "oauth2_client_credentials"
};

local allowAuthorizer = {
  handler: "allow"
};
local ketoAuthorizer(object) = {
  handler: "remote_json", config: {
  remote: main.sso.check_api_url,
  payload: |||
    {
      "namespace": "websites",
      "subject": "{{ print .Subject }}",
      "object": object,
      "relation": "access"
    }
  |||}
};

local errorRedirectHandler = {
  handler: "redirect",
  config: {
    to: main.sso.login_url,
    return_to_query_param: "return_to"
  }
};

local idTokenMutator = {handler: "id_token"};

local headerMutator = {handler: "header"};

{
  authenticators: {
    cookieSession: cookieSessionAuthenticator,
    oauth2ClientCredentials: oauth2ClientCredentialsAuthenticator,
  },
  authorizers: {
    keto: ketoAuthorizer,
    allow: allowAuthorizer,
  },
  errors: {
    redirect: errorRedirectHandler,
  },
  mutators: {
    idToken: idTokenMutator,
    header: headerMutator
  },
  allHttpMethods: ["OPTIONS", "GET", "POST", "PUT", "PATCH", "DELETE"],
}