Http.login + Templates

I want to accomplish something similar to the post Help with http.login and Google Auth wherein http.login (with Google Auth) and login.jwt are used to protect content under the /project directory, Google oAuth, a specific domain is authorized (example.com), if someone is not in that domain an error is shown they are not using an authorized account and if someone is in that domain they are sent back to the /project directory to view the content.

I’m able to accomplish all items except #4: Showing an error message for those who are not in the approved domain. From the above post it appears the OP was not able to accomplish this either.

Is there any way to use the role functionality in a template? Or any other suggestion for how to accomplish this task?

You could possibly use this new feature added recently (not available in current version):
https://github.com/tarent/loginsrv/commit/15423135b3c55ecbe4ca31d4247e4b022e313ecc

It is related to this PR: feat: add support to get logged user as json by perenecabuto · Pull Request #93 · tarent/loginsrv · GitHub

You should also be able to use {{.Domain}} in a template.

It really depends on what you exactly want to do.

Ref:

Thanks @magikstm! This might work. I will take a closer look. Does it expose a user’s role from the user_file?

I want to start with limiting access to our domain but might want to add individual email accounts, for a vendor for example. Limiting by role might be the best route.

Does it expose a user’s role from the user_file?

At the moment it doesn’t.

But, according to the docs:

To match an entry, the user file is searched in linear order and all attributes has to match the data of the authentication backend. The first matching entry will be used and all parameters below the claim attribute are written into the token.

Ref:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.