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

Restrict access to docs #22

Closed
jogaco opened this issue Jul 30, 2014 · 5 comments
Closed

Restrict access to docs #22

jogaco opened this issue Jul 30, 2014 · 5 comments

Comments

@jogaco
Copy link
Contributor

jogaco commented Jul 30, 2014

I'd like to restrict access to the documentation to logged-in users. I use devise for authentication. I guess this is not implemented, right?

@jejacks0n
Copy link
Owner

Mount the engine within a constraint or inherit the controller. Both are pretty basic approaches.

I think devise even has an "authenticated" routing constraint.


Jeremy Jackson

On Jul 30, 2014, at 4:57 AM, "J. Garcia" notifications@github.com wrote:

I'd like to restrict access to the documentation to logged-in users. I use devise for authentication. I guess this is not implemented, right?


Reply to this email directly or view it on GitHub.

@jogaco
Copy link
Contributor Author

jogaco commented Jul 30, 2014

I've been trying to extend the controller with no luck. The extended controller would never be called.
Any pointer on how to achieve either option would be appreciated.

@jejacks0n
Copy link
Owner

https://github.com/plataformatec/devise/blob/master/lib/devise/rails/routes.rb#L295

  1. configure apitome to not mount itself (covered in the readme) by setting mount_at to nil.
  2. in your routes:
authenticated do
  mount Apitome::Engine => '/your_custom_path'
end

You can adjust the authenticated constraint as you need, as outlined in the code at the above link. It should be noted that this isn't at all related to apitome, but you're welcome. =)

@jogaco
Copy link
Contributor Author

jogaco commented Jul 31, 2014

Many thanks for the tip.
I ended up securing the route within the controller, to give a chance to the user to authenticate.

class ApidocsController < Apitome::DocsController
    before_filter :authenticate_user!

    def index
        super
    end
end

@jejacks0n
Copy link
Owner

cool. you can omit the index method fyi, as it will make it into the super by default.

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

No branches or pull requests

2 participants