rls_auth.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "rls_auth.h"
  2. #if 0
  3. static int get_user_from_uri(str_t *uri, str_t *user)
  4. {
  5. char *a;
  6. char *d;
  7. char *s;
  8. /* we can't use SER's parser - the uri may have not the protocol prefix! */
  9. str_clear(user);
  10. if (uri->len > 0) {
  11. d = strchr(uri->s, ':');
  12. if (d) s = d + 1;
  13. else s = uri->s;
  14. a = strchr(s, '@');
  15. if (a) {
  16. user->s = s;
  17. user->len = a - s;
  18. return 0;
  19. }
  20. }
  21. return -1;
  22. }
  23. static authorization_result_t authorize_implicit(struct _subscription_data_t *s)
  24. {
  25. str_t user, list;
  26. str_t list_user, list_rest;
  27. str_t appendix = { s: "-list", len: 5 };
  28. if (get_user_from_uri(&s->subscriber, &user) != 0)
  29. return auth_unresolved; /* we can't decide - it is not "implicit" uri */
  30. if (get_user_from_uri(&s->record_id, &list) != 0)
  31. return auth_unresolved; /* we can't decide - it is not "implicit" uri */
  32. if (list.len <= appendix.len)
  33. return auth_unresolved; /* we can't decide - it is not "implicit" uri */
  34. list_rest.len = appendix.len;
  35. list_rest.s = list.s + list.len - appendix.len;
  36. if (str_case_equals(&list_rest, &appendix) != 0)
  37. return auth_unresolved; /* we can't decide - it is not "implicit" uri */
  38. /* now we know, that it ends with implicit uri ending */
  39. list_user.s = list.s;
  40. list_user.len = list.len - appendix.len;
  41. if (str_case_equals(&user, &list_user) != 0) return auth_rejected;
  42. else return auth_granted;
  43. }
  44. #endif
  45. authorization_result_t rls_authorize_subscription(struct _subscription_data_t *s)
  46. {
  47. switch (rls_auth_params.type) {
  48. case rls_auth_none:
  49. return auth_granted; /* ! no auth done ! */
  50. case rls_auth_implicit:
  51. return auth_granted; /* ! no auth done ! */
  52. /* return authorize_implicit(s); */
  53. case rls_auth_xcap:
  54. LOG(L_ERR, "XCAP auth for resource lists not done yet!\n");
  55. return auth_unresolved;
  56. }
  57. return auth_unresolved;
  58. }