auth: allow external accounts to login and restrict upload - #2091
Conversation
jrcastro2
left a comment
There was a problem hiding this comment.
Good job! Looks neat!
I would add some comments explaining that some values are only present in the CERN users and others on external accounts. I would maybe also check with the Auth team that the sub value is always present in all non cern accounts, and if not ask them which one we could use.
Also did you manage to test it locally with an external account?
Yes, I tested with |
04db2f8 to
464f35f
Compare
| raw_username = resource.get("preferred_username") or email | ||
| if "@" in raw_username: | ||
| raw_username = raw_username.split("@")[0] |
There was a problem hiding this comment.
We should find a better way for username, it should be unique
There was a problem hiding this comment.
@zzacharo do you have any idea for username?
464f35f to
105c5da
Compare
4f35af1 to
53ab9ed
Compare
742efb1 to
76914a1
Compare
|
|
||
| with db.session.begin_nested(): | ||
| external_id = resource.get("cern_uid") | ||
| external_id = resource.get("cern_uid") or resource.get("sub") |
There was a problem hiding this comment.
What is the sub key here? Is it unique?
76914a1 to
33844bd
Compare
33844bd to
264c5a4
Compare
6101ab8 to
d043bae
Compare
| external_id = str(external_id) | ||
| raw_username = resource.get("preferred_username") or email | ||
| if "@" in raw_username: | ||
| raw_username = raw_username.replace("@", "_").replace(".", "_") |
There was a problem hiding this comment.
in which cases we have a . and you replace it?
There was a problem hiding this comment.
If we have @ in preferred_username which is email/gmail account, you have ......@gmail.com and as username . also invalid. that's why I'm replacing but it can change
There was a problem hiding this comment.
Interesting, we did not do that in CDS-RDM. We are using the sub for the username, see here.
d043bae to
e59cef4
Compare
| external_id = str(external_id) | ||
| raw_username = resource.get("preferred_username") or email | ||
| if "@" in raw_username: | ||
| raw_username = raw_username.replace("@", "_").replace(".", "_") |
There was a problem hiding this comment.
Interesting, we did not do that in CDS-RDM. We are using the sub for the username, see here.
| cds roles add admin@test.ch admin | ||
| cds access allow deposit-admin-access role admin | ||
| cds access allow superuser-access role admin | ||
| cds access allow videos-upload-access role cern-user |
There was a problem hiding this comment.
remember to apply this when deploying. You might want to already do it in all instances to be sure that you don't forget.
In SSO application:
cern-usershould change to notrequiredMinimum Level of Assuranceand identifierauthenticated-user.This role is required to access my applicationThis role applies to all authenticated usersPermissions:
cern-userto upload/create.TODO
Uploadbutton from the top navbar