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

Disabling /api and /api/swagger endpoints #3498

Closed
0rzech opened this issue Feb 12, 2018 · 15 comments
Closed

Disabling /api and /api/swagger endpoints #3498

0rzech opened this issue Feb 12, 2018 · 15 comments
Labels
type/enhancement An improvement of existing functionality type/proposal The new feature has not been accepted yet but needs to be discussed first.
Milestone

Comments

@0rzech
Copy link
Contributor

0rzech commented Feb 12, 2018

It would be nice, if there were options to disable /api and /api/swagger endpoints.

@0rzech 0rzech changed the title Disabling /swagger and /api Disabling /api and /api/swagger endpoints Feb 12, 2018
@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

What is use case for disabling API?

@lafriks lafriks added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Feb 12, 2018
@0rzech
Copy link
Contributor Author

0rzech commented Feb 12, 2018

When one doesn't want to expose it at all, eg. to reduce attack surface.

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

You can use nginx in front of gitea and than disable everything starting with /api

@0rzech
Copy link
Contributor Author

0rzech commented Feb 12, 2018

Yes, but the link to API will remain in footer.

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

It will not work anyway ;) not the best option but you can change template if that is really needed

@0rzech
Copy link
Contributor Author

0rzech commented Feb 12, 2018

Yes, but IMHO it's a bit too dirty to change template and server configuration to achieve that.

@lafriks
Copy link
Member

lafriks commented Feb 12, 2018

Of course option to hide swagger link can be added

@0rzech
Copy link
Contributor Author

0rzech commented Feb 12, 2018

Cool. Thanks for your input.

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 17, 2018
@lunny lunny added this to the 1.5.0 milestone Feb 17, 2018
@lunny lunny added type/enhancement An improvement of existing functionality and removed type/feature Completely new functionality. Can only be merged if feature freeze is not active. labels Feb 17, 2018
@lunny
Copy link
Member

lunny commented Feb 17, 2018

resolved by #3502

@lunny lunny closed this as completed Feb 17, 2018
@shuhaowu
Copy link

The other PR doesn't actually disable /api, right? Only /api/swagger (which is the documentation endpoint and try it out interface??) is disabled in that PR afaict.

Thus this is not quite resolved with that option. To work around this, you can disable access to /api in the reverse proxy setup link nginx on the node. The /api/internal endpoints should stay unaffected with this because gitea by default tries to build the internal API calls' urls via HTTP_ADDR:HTTP_PORT specified in the settings, which doesn't go through the reverse proxy locally. Just ensure that you only bind with HTTP_ADDR = 127.0.0.1.

@lafriks
Copy link
Member

lafriks commented Jun 13, 2018

@shuhaowu not true, gitea also uses API for some functionality so it can not be disabled fully without loosing some functionality

@shuhaowu
Copy link

Yeah but my work around shouldn't impact it? As I can see in the code, any API calls gitea does uses LocalURL, which is HTTP_ADDR:HTTP_PORT if running in the regular server mode, correct?

@0rzech
Copy link
Contributor Author

0rzech commented Jul 30, 2018

@shuhaowu Gitea front-end uses API as well. You can find it here. Just look for /api occurrences.

@gerroon
Copy link

gerroon commented May 16, 2020

What is use case for disabling API?

I just realized that non users can get user names without signed in, I do not know how this is not a security issue.

Here is from non public repo, using from terminal without any form of login indication. There is not even an API key involved.

curl -X GET "https://DOMAIN/GIT/gc/api/v1/users/search?q=USE" -H  "accept: application/json"


{"data":[{"id":0,"login":"USER","full_name":"","email":"","avatar_url":"https://DOMAIN/GIT/gc/user/avatar/USER/-1","language":"","is_admin":false,"last_login":"0001-01-01T00:00:00Z","created":"2018-05-21T22:45:38-05:00","username":"USER"}],"ok":true}



@techknowlogick
Copy link
Member

@gerroon you can get the same information from the webapp itself example: https://try.gitea.io/explore/users

This ticket is closed, if you have a feature request please create a new issue, however disabling the API is not possible as mentioned above the web interface makes use of it.

@go-gitea go-gitea locked and limited conversation to collaborators May 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/enhancement An improvement of existing functionality type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

No branches or pull requests

6 participants