Example of custom authentication provider with SampleAuth

General discussion about MantisBT Plugins

Moderators: Developer, Contributor

Post Reply
tasso85
Posts: 1
Joined: Apr 29, 2019 6:15 am

Example of custom authentication provider with SampleAuth

Post by tasso85 » Apr 29, 2019 6:20 am

Hi everyone,

I wanted to ask if there is a "working example" of how to implement a custom authentication flow in mantis.

I have checked the SampleAuth plugin on github, but found it hasn't a complete example.

What I would like to implement in mantis is the following flow:
- check username against another database (that is, not mantis own database)
- if user exists, check password against that other database
- if check ok, and user not already in local mantis database, create it with no password and assign role derived from user role on other database
- finally, set the needed session values and let user proceed

Is there any example of a similar flow, or more generically of a custom one not involving LDAP or OpenID/OAuth, just a different (maybe remote) database?

Starbuck
Posts: 180
Joined: Feb 13, 2006 9:53 pm
Location: USA
Contact:

Re: Example of custom authentication provider with SampleAuth

Post by Starbuck » May 17, 2019 3:08 pm

The approach I would take with this is to look into the Mantis code to see how it determines whether a user is logged in, and what it does when a user is not. Then: Is there a hook there for alternative behavior?
If so, look to see what a hooked event handler needs to accept and return.
If not, see what the hard-coded login routine does to return a value that then leads the user back to the original page. Look to see how to fire an event at that point. Insert an event handler that will avoid other default code when your code has provided all required data.
Submit your event hook as a Github PR for addition into the core.
Then when a future version of Mantis is published, it will automatically call your code to do exactly what you want.

Any help as a high-level guide?
If you want Mantis to work differently, use or create a plugin. Visit the Plugins forums.
Ask developers to create a plugin that you need - and motivate them to help you!

Post Reply