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

Modular auth backend #1162

Closed
wants to merge 12 commits into from

Conversation

a-martynovich
Copy link
Contributor

Closes #1148

Introduce abstract Auth class, BasicAuth providing HTTP Authentication and its dummy subclass WoTTAuth.
Move assetdir initialization to a separate function run by Flask.
Let Auth classes specify their config.
Rewrite auth settings update procedure.
Add NoAuth backend ("Disabled").

class BasicAuth(Auth):
name = 'Basic'
id = 'auth_basic'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, it is not considered a good practice to have anything named by builtins.

def template(self):
return 'auth_basic.html', {'user': self.settings['user']}

def authenticate(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not exactly doing what is written in the docstring.
Also, seems terms authorize and authenticated are used a bit confusing
http://cdn.differencebetween.net/wp-content/uploads/2017/10/Difference-between-Authentication-and-Authorization.png

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with your statement about terminology. I’ll come up with something better.
However the function does exactly what the docstring says: initiates authentication. Okay, the browser initiates it as a result of getting 401. But if we will have another auth backend which can generate its own login page that’s what this function will return. And that will truly initiate authentication.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But looking at the authorize function above it seems like authenticate is used to always return fail response.

if not self.is_authorized:
   return self.authenticate()

self.auth_backends_list = [NoAuth(), BasicAuth(self), WoTTAuth(self)]
self.auth_backends = {}
for b in self.auth_backends_list:
c = b.config

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor : b and c are not readable names.

@a-martynovich
Copy link
Contributor Author

Closed in favor of #1165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor auth backend to make it dynamic
2 participants