Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

feat: add hooking point for AUTHORIZE #339

Merged
merged 3 commits into from
Oct 5, 2020
Merged

Conversation

adrysn
Copy link
Member

@adrysn adrysn commented Oct 5, 2020

This PR adds hooking point for AUTHORIZE with the FIRST_COMPLETED requirement.

  • The hook accepts params and dbpool parameters. Especially, dbpool is needed to access DB from the hook.
  • When any one of AUTHORIZE hook is passed, the user object returned by the hook is used .
    • Thus, each AUTHORIZE hook should ensure that a corresponding Backend.AI account exists.
  • For example, LDAP hook may perform the following jobs:
    • Check if the user's login credential (email, password) passes the authentication from LDAP server.
      • If not passed, just reject the request.
    • If passed, ensure a Backend.AI account with the same email exists.
      • If it does not exist, create a new Backend.AI account
    • Return the existing or new user object.
  • If there is no AUTHORIZE hook in the manager, just performs normal check_credential authentication process.

Related LDAP hook implementation: https://github.com/lablup/backend.ai-ldap-plugin/pull/1

@adrysn adrysn self-assigned this Oct 5, 2020
@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #339 into master will decrease coverage by 0.04%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #339      +/-   ##
==========================================
- Coverage   47.56%   47.51%   -0.05%     
==========================================
  Files          48       48              
  Lines        7491     7498       +7     
==========================================
  Hits         3563     3563              
- Misses       3928     3935       +7     
Impacted Files Coverage Δ
src/ai/backend/gateway/auth.py 52.40% <0.00%> (-1.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76ff249...c85f72a. Read the comment docs.

@adrysn adrysn requested a review from achimnol October 5, 2020 09:25
@adrysn adrysn added this to the 20.03 milestone Oct 5, 2020
@adrysn adrysn changed the title feat: add-authorize-hook feat: add hooking point for AUTHORIZE Oct 5, 2020
@achimnol achimnol merged commit 0e4bfb5 into master Oct 5, 2020
@achimnol achimnol deleted the feat/add-authorize-hook branch October 5, 2020 14:37
achimnol pushed a commit that referenced this pull request Oct 6, 2020
…ocess (#339)

Backported-From: master
Backported-To: 20.03
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants