Skip to content

Commit

Permalink
Orca: Integrate with keycloak (#84)
Browse files Browse the repository at this point in the history
- fetch jwk from keycloak (depending on config)
- validate JWTs issued by keycloak based on JWKs
- verify resource roles from keycloak
- implement basic stats api using keycloak authorization
  • Loading branch information
turboMaCk authored and ICTGuerrilla committed Aug 31, 2023
1 parent 94d566d commit 148534c
Show file tree
Hide file tree
Showing 19 changed files with 648 additions and 31 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/acceptance-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
ROCKET_SMTP_HOST: "localhost"
ROCKET_SMTP_USER: ""
ROCKET_SMTP_PASSWORD: ""
ROCKET_KEYCLOAK_HOST: "https://keycloak.ictunion.cz"
ROCKET_KEYCLOAK_REALM: "testing-members"

- name: Check status of orca
run: |
Expand Down
2 changes: 1 addition & 1 deletion administration-panel/src/keycloak.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Keycloak from 'keycloak-js';
import config, { Url } from './config';
import config from './config';

export interface UserInfo {
name: string,
Expand Down
46 changes: 46 additions & 0 deletions gray-whale/migrations/V8__add_registration_views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- Make members number unique
ALTER TABLE members ADD UNIQUE (member_number);

-- Add rejceted at column to registration requests
ALTER TABLE registration_requests
ADD COLUMN rejected_at TIMESTAMPTZ;

COMMENT ON COLUMN registration_requests.rejected_at IS 'Time when request was rejected. If NULL then it was never rejected';

-- Create views

CREATE OR REPLACE VIEW registration_requests_unverified AS
SELECT * FROM registration_requests rr
WHERE rr.confirmed_at IS NULL
AND rr.rejected_at IS NULL
AND NOT EXISTS (SELECT id FROM members m WHERE rr.id = m.registration_request_id);

COMMENT ON VIEW registration_requests_unverified IS 'All registration requests which are waiting on email confirmation';

GRANT SELECT ON registration_requests_unverified TO orca;

CREATE OR REPLACE VIEW registration_requests_accepted AS
SELECT * FROM registration_requests rr
WHERE EXISTS (SELECT id FROM members m WHERE rr.id = m.registration_request_id);

COMMENT ON VIEW registration_requests_accepted IS 'All registration requests that were accepted (as members)';

GRANT SELECT ON registration_requests_accepted TO orca;

CREATE OR REPLACE VIEW registration_requests_rejected AS
SELECT * FROM registration_requests rr
WHERE rr.rejected_at IS NOT NULL;

COMMENT ON VIEW registration_requests_rejected IS 'All registration requests that were rejected';

GRANT SELECT ON registration_requests_rejected TO orca;

CREATE OR REPLACE VIEW registration_requests_procession AS
SELECT * FROM registration_requests rr
WHERE rr.confirmed_at IS NOT NULL
AND rr.rejected_at IS NULL
AND NOT EXISTS (SELECT id FROM members m WHERE rr.id = m.registration_request_id);

COMMENT ON VIEW registration_requests_procession IS 'All registrations which are confirmed by applicant but are not yet either rejected or accepted';

GRANT SELECT ON registration_requests_procession TO orca;
Loading

0 comments on commit 148534c

Please sign in to comment.